home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / U-Z / VideoToolbox 4.95.sit / VideoToolbox / VideoToolboxSources / NoisePdfFill.c < prev    next >
MacBinary  |  1995-04-18  |  16.5 KB  |  [TEXT/MMCC]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Tue Apr 18 03:08:00 1995, modified Tue Apr 18 03:08:00 1995, creator 'MMCC', type ASCII, 16168 bytes "NoisePdfFill.c" , at 0x3fa8 410 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MMCC]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0e 4e 6f 69 73 65 50 | 64 66 46 69 6c 6c 2e 63 |..NoiseP|dfFill.c|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 4d 43 | 43 00 00 00 00 00 00 00 |.TEXTMMC|C.......|
|00000050| 00 00 00 00 00 3f 28 00 | 00 01 9a ab b9 15 d0 ab |.....?(.|........|
|00000060| b9 15 d0 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 e9 21 00 00 |........|.....!..|
|00000080| 2f 2a 0d 4e 6f 69 73 65 | 50 64 66 46 69 6c 6c 2e |/*.Noise|PdfFill.|
|00000090| 63 0d 0d 65 72 72 6f 72 | 3d 4e 6f 69 73 65 50 64 |c..error|=NoisePd|
|000000a0| 66 46 69 6c 6c 28 77 6f | 72 6c 64 2c 26 72 65 63 |fFill(wo|rld,&rec|
|000000b0| 74 2c 70 64 66 4b 69 6e | 64 2c 26 6d 65 61 6e 2c |t,pdfKin|d,&mean,|
|000000c0| 26 73 64 2c 6d 69 6e 2c | 6d 61 78 29 3b 0d 65 72 |&sd,min,|max);.er|
|000000d0| 72 6f 72 3d 4e 6f 69 73 | 65 50 64 66 41 64 64 28 |ror=Nois|ePdfAdd(|
|000000e0| 77 6f 72 6c 64 2c 26 72 | 65 63 74 2c 70 64 66 4b |world,&r|ect,pdfK|
|000000f0| 69 6e 64 2c 26 6d 65 61 | 6e 2c 26 73 64 2c 6d 69 |ind,&mea|n,&sd,mi|
|00000100| 6e 2c 6d 61 78 29 3b 0d | 0d 47 65 6e 65 72 61 74 |n,max);.|.Generat|
|00000110| 65 20 67 6f 6f 64 20 6e | 6f 69 73 65 20 69 6d 61 |e good n|oise ima|
|00000120| 67 65 73 20 71 75 69 63 | 6b 6c 79 2e 20 59 6f 75 |ges quic|kly. You|
|00000130| 20 73 75 70 70 6c 79 20 | 61 20 47 57 6f 72 6c 64 | supply |a GWorld|
|00000140| 20 28 6f 72 20 61 20 77 | 69 6e 64 6f 77 29 20 61 | (or a w|indow) a|
|00000150| 6e 64 20 61 20 72 65 63 | 74 0d 69 6e 64 69 63 61 |nd a rec|t.indica|
|00000160| 74 69 6e 67 20 68 6f 77 | 20 6d 75 63 68 20 6f 66 |ting how| much of|
|00000170| 20 69 74 20 74 6f 20 66 | 69 6c 6c 20 77 69 74 68 | it to f|ill with|
|00000180| 20 6e 6f 69 73 65 2e 20 | 22 77 6f 72 6c 64 22 20 | noise. |"world" |
|00000190| 6d 61 79 20 62 65 20 61 | 20 70 6f 69 6e 74 65 72 |may be a| pointer|
|000001a0| 20 74 6f 20 61 0d 47 57 | 6f 72 6c 64 2c 20 61 20 | to a.GW|orld, a |
|000001b0| 63 6f 6c 6f 72 20 43 57 | 69 6e 64 6f 77 2c 20 6f |color CW|indow, o|
|000001c0| 72 2c 20 77 69 74 68 20 | 63 61 73 74 69 6e 67 2c |r, with |casting,|
|000001d0| 20 61 20 70 6c 61 69 6e | 2d 6f 6c 64 20 57 69 6e | a plain|-old Win|
|000001e0| 64 6f 77 2e 20 4e 6f 69 | 73 65 50 64 66 46 69 6c |dow. Noi|sePdfFil|
|000001f0| 6c 20 66 69 6c 6c 73 0d | 74 68 65 20 70 69 78 65 |l fills.|the pixe|
|00000200| 6c 73 20 77 69 74 68 69 | 6e 20 72 65 63 74 20 77 |ls withi|n rect w|
|00000210| 69 74 68 20 6e 6f 69 73 | 65 3b 20 4e 6f 69 73 65 |ith nois|e; Noise|
|00000220| 50 64 66 41 64 64 20 61 | 64 64 73 20 6e 6f 69 73 |PdfAdd a|dds nois|
|00000230| 65 20 74 6f 20 74 68 65 | 6d 2e 20 45 61 63 68 20 |e to the|m. Each |
|00000240| 70 69 78 65 6c 0d 77 69 | 6c 6c 20 67 65 74 20 61 |pixel.wi|ll get a|
|00000250| 6e 20 69 6e 64 65 70 65 | 6e 64 65 6e 74 20 69 6e |n indepe|ndent in|
|00000260| 74 65 67 65 72 20 73 61 | 6d 70 6c 65 20 66 72 6f |teger sa|mple fro|
|00000270| 6d 20 61 20 73 70 65 63 | 69 66 69 65 64 20 70 72 |m a spec|ified pr|
|00000280| 6f 62 61 62 69 6c 69 74 | 79 20 64 65 6e 73 69 74 |obabilit|y densit|
|00000290| 79 0d 66 75 6e 63 74 69 | 6f 6e 20 28 70 64 66 29 |y.functi|on (pdf)|
|000002a0| 3a 20 6b 42 69 6e 61 72 | 79 50 64 66 2c 20 6b 55 |: kBinar|yPdf, kU|
|000002b0| 6e 69 66 6f 72 6d 50 64 | 66 2c 20 6f 72 20 6b 47 |niformPd|f, or kG|
|000002c0| 61 75 73 73 69 61 6e 50 | 64 66 2e 20 28 41 20 66 |aussianP|df. (A f|
|000002d0| 6f 75 72 74 68 20 70 64 | 66 2c 0d 6b 42 69 6e 6f |ourth pd|f,.kBino|
|000002e0| 6d 69 61 6c 50 64 66 2c | 20 69 73 20 6e 6f 74 20 |mialPdf,| is not |
|000002f0| 72 65 63 6f 6d 6d 65 6e | 64 65 64 2e 29 20 59 6f |recommen|ded.) Yo|
|00000300| 75 20 73 70 65 63 69 66 | 79 20 74 68 65 20 70 64 |u specif|y the pd|
|00000310| 66 20 6b 69 6e 64 2c 20 | 6d 65 61 6e 2c 20 61 6e |f kind, |mean, an|
|00000320| 64 0d 22 75 6e 63 6c 69 | 70 70 65 64 22 20 73 74 |d."uncli|pped" st|
|00000330| 61 6e 64 61 72 64 20 64 | 65 76 69 61 74 69 6f 6e |andard d|eviation|
|00000340| 2e 20 54 68 65 20 6c 61 | 73 74 20 74 77 6f 20 61 |. The la|st two a|
|00000350| 72 67 75 6d 65 6e 74 73 | 2c 20 22 6d 69 6e 22 20 |rguments|, "min" |
|00000360| 61 6e 64 20 22 6d 61 78 | 22 2c 20 61 72 65 20 75 |and "max|", are u|
|00000370| 73 65 64 0d 74 6f 20 63 | 6c 69 70 2c 20 69 2e 65 |sed.to c|lip, i.e|
|00000380| 2e 20 72 65 73 74 72 69 | 63 74 20 74 68 65 20 72 |. restri|ct the r|
|00000390| 61 6e 67 65 20 6f 66 20 | 74 68 65 20 70 64 66 20 |ange of |the pdf |
|000003a0| 28 65 2e 67 2e 20 74 6f | 20 70 72 65 63 6c 75 64 |(e.g. to| preclud|
|000003b0| 65 20 6f 76 65 72 66 6c | 6f 77 20 69 6e 20 79 6f |e overfl|ow in yo|
|000003c0| 75 72 0d 69 6d 61 67 65 | 20 70 69 78 65 6c 73 29 |ur.image| pixels)|
|000003d0| 2e 20 49 6e 20 74 68 65 | 20 63 61 73 65 73 20 6f |. In the| cases o|
|000003e0| 66 20 6b 55 6e 69 66 6f | 72 6d 50 64 66 2c 20 6b |f kUnifo|rmPdf, k|
|000003f0| 42 69 6e 6f 6d 69 61 6c | 50 64 66 2c 20 61 6e 64 |Binomial|Pdf, and|
|00000400| 20 6b 47 61 75 73 73 69 | 61 6e 50 64 66 2c 0d 73 | kGaussi|anPdf,.s|
|00000410| 61 6d 70 6c 65 73 20 66 | 61 6c 6c 69 6e 67 20 6f |amples f|alling o|
|00000420| 75 74 73 69 64 65 20 74 | 68 65 20 72 61 6e 67 65 |utside t|he range|
|00000430| 20 5b 6d 69 6e 2c 6d 61 | 78 5d 20 61 72 65 20 64 | [min,ma|x] are d|
|00000440| 69 73 63 61 72 64 65 64 | 20 61 6e 64 20 72 65 70 |iscarded| and rep|
|00000450| 6c 61 63 65 64 20 62 79 | 0d 69 6e 64 65 70 65 6e |laced by|.indepen|
|00000460| 64 65 6e 74 20 6e 65 77 | 20 73 61 6d 70 6c 65 73 |dent new| samples|
|00000470| 2e 20 49 6e 20 74 68 65 | 20 63 61 73 65 20 6f 66 |. In the| case of|
|00000480| 20 6b 42 69 6e 61 72 79 | 2c 20 65 61 63 68 20 73 | kBinary|, each s|
|00000490| 61 6d 70 6c 65 20 68 61 | 73 20 6f 6e 65 20 6f 66 |ample ha|s one of|
|000004a0| 20 6f 6e 6c 79 20 74 77 | 6f 0d 76 61 6c 75 65 73 | only tw|o.values|
|000004b0| 2c 20 77 69 74 68 20 65 | 71 75 61 6c 20 70 72 6f |, with e|qual pro|
|000004c0| 62 61 62 69 6c 69 74 79 | 3b 20 74 68 65 73 65 20 |bability|; these |
|000004d0| 74 77 6f 20 76 61 6c 75 | 65 73 20 61 72 65 20 69 |two valu|es are i|
|000004e0| 6e 69 74 69 61 6c 6c 79 | 20 73 65 74 20 74 6f 20 |nitially| set to |
|000004f0| 6d 65 61 6e b1 73 64 2c | 20 74 6f 0d 79 69 65 6c |mean.sd,| to.yiel|
|00000500| 64 20 74 68 65 20 64 65 | 73 69 72 65 64 20 6d 65 |d the de|sired me|
|00000510| 61 6e 20 61 6e 64 20 73 | 64 2c 20 62 75 74 20 74 |an and s|d, but t|
|00000520| 68 65 79 20 61 72 65 20 | 61 64 6a 75 73 74 65 64 |hey are |adjusted|
|00000530| 2c 20 69 66 20 6e 65 63 | 65 73 73 61 72 79 2c 20 |, if nec|essary, |
|00000540| 74 6f 20 62 72 69 6e 67 | 20 74 68 65 6d 0d 77 69 |to bring| them.wi|
|00000550| 74 68 69 6e 20 74 68 65 | 20 72 61 6e 67 65 20 5b |thin the| range [|
|00000560| 6d 69 6e 2c 6d 61 78 5d | 2e 20 55 70 6f 6e 20 72 |min,max]|. Upon r|
|00000570| 65 74 75 72 6e 2c 20 74 | 68 65 20 6d 65 61 6e 20 |eturn, t|he mean |
|00000580| 61 6e 64 20 73 64 20 61 | 72 67 75 6d 65 6e 74 73 |and sd a|rguments|
|00000590| 20 28 77 68 69 63 68 20 | 61 72 65 0d 70 61 73 73 | (which |are.pass|
|000005a0| 65 64 20 62 79 20 72 65 | 66 65 72 65 6e 63 65 2c |ed by re|ference,|
|000005b0| 20 69 2e 65 2e 20 62 79 | 20 61 64 64 72 65 73 73 | i.e. by| address|
|000005c0| 2c 20 6e 6f 74 20 62 79 | 20 76 61 6c 75 65 29 20 |, not by| value) |
|000005d0| 72 65 74 75 72 6e 20 74 | 68 65 20 6d 65 61 6e 20 |return t|he mean |
|000005e0| 61 6e 64 20 73 74 61 6e | 64 61 72 64 0d 64 65 76 |and stan|dard.dev|
|000005f0| 69 61 74 69 6f 6e 20 6f | 66 20 74 68 65 20 72 61 |iation o|f the ra|
|00000600| 6e 64 6f 6d 20 67 65 6e | 65 72 61 74 6f 72 20 6f |ndom gen|erator o|
|00000610| 66 20 74 68 65 20 73 61 | 6d 70 6c 65 73 20 28 69 |f the sa|mples (i|
|00000620| 2e 65 2e 20 74 68 65 20 | 63 6c 69 70 70 65 64 20 |.e. the |clipped |
|00000630| 70 64 66 29 2e 0d 0d 54 | 68 65 20 72 65 71 75 65 |pdf)...T|he reque|
|00000640| 73 74 65 64 20 73 74 61 | 6e 64 61 72 64 20 64 65 |sted sta|ndard de|
|00000650| 76 69 61 74 69 6f 6e 2c | 20 73 64 2c 20 6d 75 73 |viation,| sd, mus|
|00000660| 74 20 62 65 20 67 72 65 | 61 74 65 72 20 74 68 61 |t be gre|ater tha|
|00000670| 6e 20 6f 72 20 65 71 75 | 61 6c 20 74 6f 20 7a 65 |n or equ|al to ze|
|00000680| 72 6f 2e 20 54 68 65 0d | 73 70 65 63 69 61 6c 20 |ro. The.|special |
|00000690| 63 61 73 65 20 6f 66 20 | 7a 65 72 6f 20 73 74 61 |case of |zero sta|
|000006a0| 6e 64 61 72 64 20 64 65 | 76 69 61 74 69 6f 6e 20 |ndard de|viation |
|000006b0| 69 73 20 72 65 63 6f 67 | 6e 69 7a 65 64 20 61 6e |is recog|nized an|
|000006c0| 64 20 70 65 72 66 6f 72 | 6d 65 64 20 71 75 69 63 |d perfor|med quic|
|000006d0| 6b 6c 79 2c 0d 70 72 6f | 64 75 63 69 6e 67 20 61 |kly,.pro|ducing a|
|000006e0| 20 75 6e 69 66 6f 72 6d | 20 69 6d 61 67 65 20 77 | uniform| image w|
|000006f0| 69 74 68 20 73 70 65 63 | 69 66 69 65 64 20 6d 65 |ith spec|ified me|
|00000700| 61 6e 2e 20 41 20 72 65 | 71 75 65 73 74 20 66 6f |an. A re|quest fo|
|00000710| 72 20 61 6e 20 75 6e 61 | 63 68 69 65 76 61 62 6c |r an una|chievabl|
|00000720| 79 20 6c 6f 77 2c 0d 62 | 75 74 20 6e 6f 6e 7a 65 |y low,.b|ut nonze|
|00000730| 72 6f 2c 20 73 64 20 77 | 69 6c 6c 20 62 65 20 73 |ro, sd w|ill be s|
|00000740| 65 72 76 65 64 20 62 79 | 20 70 72 6f 76 69 64 69 |erved by| providi|
|00000750| 6e 67 20 74 68 65 20 6c | 6f 77 65 73 74 20 61 63 |ng the l|owest ac|
|00000760| 68 69 65 76 61 62 6c 65 | 20 73 64 20 28 67 69 76 |hievable| sd (giv|
|00000770| 65 6e 20 74 68 65 0d 73 | 70 65 63 69 66 69 65 64 |en the.s|pecified|
|00000780| 20 6d 69 6e 20 61 6e 64 | 20 6d 61 78 29 2c 20 6f | min and| max), o|
|00000790| 6e 20 74 68 65 20 70 72 | 65 6d 69 73 20 74 68 61 |n the pr|emis tha|
|000007a0| 74 20 74 68 65 20 75 73 | 65 72 20 63 61 72 65 73 |t the us|er cares|
|000007b0| 20 6d 6f 73 74 20 61 62 | 6f 75 74 20 6c 6f 67 20 | most ab|out log |
|000007c0| 73 64 2c 20 73 6f 0d 74 | 68 61 74 20 74 68 65 20 |sd, so.t|hat the |
|000007d0| 6c 65 61 73 74 20 70 6f | 73 73 69 62 6c 65 20 6e |least po|ssible n|
|000007e0| 6f 6e 7a 65 72 6f 20 73 | 64 20 77 69 6c 6c 20 62 |onzero s|d will b|
|000007f0| 65 20 61 20 62 65 74 74 | 65 72 20 61 70 70 72 6f |e a bett|er appro|
|00000800| 78 69 6d 61 74 69 6f 6e | 20 74 6f 20 61 6e 0d 75 |ximation| to an.u|
|00000810| 6e 61 63 68 69 65 76 61 | 62 6c 79 20 6c 6f 77 20 |nachieva|bly low |
|00000820| 73 64 20 74 68 61 6e 20 | 77 6f 75 6c 64 20 7a 65 |sd than |would ze|
|00000830| 72 6f 20 73 64 2e 20 53 | 75 70 70 6c 79 69 6e 67 |ro sd. S|upplying|
|00000840| 20 61 6e 20 73 64 20 6f | 66 20 49 4e 46 20 77 69 | an sd o|f INF wi|
|00000850| 6c 6c 20 70 72 6f 64 75 | 63 65 0d 73 61 6d 70 6c |ll produ|ce.sampl|
|00000860| 65 73 20 77 69 74 68 20 | 76 61 6c 75 65 73 20 6f |es with |values o|
|00000870| 66 20 6d 69 6e 20 61 6e | 64 20 6d 61 78 20 69 66 |f min an|d max if|
|00000880| 20 74 68 65 20 70 64 66 | 20 6b 69 6e 64 20 69 73 | the pdf| kind is|
|00000890| 20 6b 42 69 6e 61 72 79 | 50 64 66 2c 20 61 6e 64 | kBinary|Pdf, and|
|000008a0| 20 77 69 6c 6c 0d 70 72 | 6f 64 75 63 65 20 61 20 | will.pr|oduce a |
|000008b0| 75 6e 69 66 6f 72 6d 20 | 64 69 73 74 72 69 62 75 |uniform |distribu|
|000008c0| 74 69 6f 6e 20 6f 76 65 | 72 20 74 68 65 20 72 61 |tion ove|r the ra|
|000008d0| 6e 67 65 20 5b 6d 69 6e | 2c 6d 61 78 5d 20 69 66 |nge [min|,max] if|
|000008e0| 20 74 68 65 20 70 64 66 | 20 69 73 0d 6b 55 6e 69 | the pdf| is.kUni|
|000008f0| 66 6f 72 6d 50 64 66 2c | 20 6b 47 61 75 73 73 69 |formPdf,| kGaussi|
|00000900| 61 6e 50 64 66 2c 20 6f | 72 20 6b 42 69 6e 6f 6d |anPdf, o|r kBinom|
|00000910| 69 61 6c 50 64 66 2e 0d | 0d 22 6d 61 78 22 20 6d |ialPdf..|."max" m|
|00000920| 75 73 74 20 62 65 20 67 | 72 65 61 74 65 72 20 74 |ust be g|reater t|
|00000930| 68 61 6e 20 6f 72 20 65 | 71 75 61 6c 20 74 6f 20 |han or e|qual to |
|00000940| 22 6d 65 61 6e 22 2c 20 | 77 68 69 63 68 20 6d 75 |"mean", |which mu|
|00000950| 73 74 20 62 65 20 67 72 | 65 61 74 65 72 20 74 68 |st be gr|eater th|
|00000960| 61 6e 20 6f 72 0d 65 71 | 75 61 6c 20 74 6f 20 22 |an or.eq|ual to "|
|00000970| 6d 69 6e 22 2e 20 4e 6f | 72 6d 61 6c 6c 79 2c 20 |min". No|rmally, |
|00000980| 69 6d 61 67 65 20 70 69 | 78 65 6c 73 20 61 72 65 |image pi|xels are|
|00000990| 20 63 6f 6e 73 69 64 65 | 72 65 64 20 70 6f 73 69 | conside|red posi|
|000009a0| 74 69 76 65 20 61 6e 64 | 20 79 6f 75 27 6c 6c 20 |tive and| you'll |
|000009b0| 77 61 6e 74 20 74 6f 0d | 6d 61 6b 65 20 22 6d 69 |want to.|make "mi|
|000009c0| 6e 22 20 67 72 65 61 74 | 65 72 20 74 68 61 6e 20 |n" great|er than |
|000009d0| 6f 72 20 65 71 75 61 6c | 20 74 6f 20 7a 65 72 6f |or equal| to zero|
|000009e0| 2c 20 62 75 74 20 74 68 | 69 73 20 69 73 20 6e 6f |, but th|is is no|
|000009f0| 74 20 65 6e 66 6f 72 63 | 65 64 20 62 79 0d 4e 6f |t enforc|ed by.No|
|00000a00| 69 73 65 50 64 66 46 69 | 6c 6c 3b 20 65 2e 67 2e |isePdfFi|ll; e.g.|
|00000a10| 20 79 6f 75 20 63 61 6e | 20 61 64 64 20 7a 65 72 | you can| add zer|
|00000a20| 6f 2d 6d 65 61 6e 20 6e | 6f 69 73 65 20 74 6f 20 |o-mean n|oise to |
|00000a30| 61 20 70 6f 73 69 74 69 | 76 65 20 69 6d 61 67 65 |a positi|ve image|
|00000a40| 2e 20 0d 0d 43 61 6c 6c | 69 6e 67 20 4e 6f 69 73 |. ..Call|ing Nois|
|00000a50| 65 50 64 66 41 64 64 20 | 77 69 74 68 20 61 20 22 |ePdfAdd |with a "|
|00000a60| 6d 69 6e 22 3c 30 20 73 | 68 6f 75 6c 64 20 77 6f |min"<0 s|hould wo|
|00000a70| 72 6b 20 70 65 72 66 65 | 63 74 6c 79 20 28 74 68 |rk perfe|ctly (th|
|00000a80| 6f 75 67 68 20 69 74 20 | 68 61 73 6e 27 74 20 62 |ough it |hasn't b|
|00000a90| 65 65 6e 0d 74 65 73 74 | 65 64 29 2c 20 62 75 74 |een.test|ed), but|
|00000aa0| 20 6d 61 79 20 62 65 20 | 73 69 67 6e 69 66 69 63 | may be |signific|
|00000ab0| 61 6e 74 6c 79 20 73 6c | 6f 77 65 72 20 74 68 61 |antly sl|ower tha|
|00000ac0| 6e 20 77 68 65 6e 20 22 | 6d 69 6e 22 b3 30 2e 20 |n when "|min".0. |
|00000ad0| 4e 6f 69 73 65 50 64 66 | 41 64 64 28 29 20 75 73 |NoisePdf|Add() us|
|00000ae0| 65 73 0d 4e 6f 69 73 65 | 50 64 66 46 69 6c 6c 28 |es.Noise|PdfFill(|
|00000af0| 29 20 74 6f 20 6d 61 6b | 65 20 74 68 65 20 6e 6f |) to mak|e the no|
|00000b00| 69 73 65 20 69 6e 20 61 | 20 74 65 6d 70 6f 72 61 |ise in a| tempora|
|00000b10| 72 79 20 6e 65 77 20 47 | 57 6f 72 6c 64 20 61 6e |ry new G|World an|
|00000b20| 64 20 74 68 65 6e 20 63 | 61 6c 6c 73 0d 43 6f 70 |d then c|alls.Cop|
|00000b30| 79 57 69 6e 64 6f 77 73 | 20 74 6f 20 61 64 64 20 |yWindows| to add |
|00000b40| 74 68 65 20 6e 6f 69 73 | 65 20 74 6f 20 79 6f 75 |the nois|e to you|
|00000b50| 72 20 69 6d 61 67 65 2e | 20 49 66 20 22 6d 69 6e |r image.| If "min|
|00000b60| 22 b3 30 20 74 68 65 6e | 20 4e 6f 69 73 65 50 64 |".0 then| NoisePd|
|00000b70| 66 41 64 64 28 29 20 75 | 73 65 73 20 61 0d 66 61 |fAdd() u|ses a.fa|
|00000b80| 73 74 20 70 61 72 61 6c | 6c 65 6c 20 61 64 64 69 |st paral|lel addi|
|00000b90| 74 69 6f 6e 20 74 68 61 | 74 20 61 73 73 75 6d 65 |tion tha|t assume|
|00000ba0| 73 20 74 68 65 72 65 20 | 77 69 6c 6c 20 62 65 20 |s there |will be |
|00000bb0| 6e 6f 20 6f 76 65 72 66 | 6c 6f 77 20 69 6e 20 65 |no overf|low in e|
|00000bc0| 61 63 68 20 70 69 78 65 | 6c 27 73 0d 61 72 69 74 |ach pixe|l's.arit|
|00000bd0| 68 6d 65 74 69 63 2c 20 | 73 6f 20 74 68 65 20 75 |hmetic, |so the u|
|00000be0| 73 65 72 20 73 68 6f 75 | 6c 64 20 74 61 6b 65 20 |ser shou|ld take |
|00000bf0| 63 61 72 65 20 74 6f 20 | 73 70 65 63 69 66 79 20 |care to |specify |
|00000c00| 61 20 22 6d 61 78 22 20 | 74 68 61 74 20 77 69 6c |a "max" |that wil|
|00000c10| 6c 20 69 6e 64 65 65 64 | 0d 70 72 65 76 65 6e 74 |l indeed|.prevent|
|00000c20| 20 6f 76 65 72 66 6c 6f | 77 2c 20 73 69 6e 63 65 | overflo|w, since|
|00000c30| 20 61 6e 79 20 6f 76 65 | 72 66 6c 6f 77 20 77 6f | any ove|rflow wo|
|00000c40| 75 6c 64 20 61 66 66 65 | 63 74 20 61 20 6e 65 69 |uld affe|ct a nei|
|00000c50| 67 68 62 6f 72 69 6e 67 | 20 70 69 78 65 6c 2e 20 |ghboring| pixel. |
|00000c60| 49 66 20 22 6d 69 6e 22 | 3c 30 0d 74 68 65 6e 20 |If "min"|<0.then |
|00000c70| 74 68 65 20 75 6e 73 69 | 67 6e 65 64 20 61 64 64 |the unsi|gned add|
|00000c80| 69 74 69 6f 6e 20 6f 66 | 20 22 6e 65 67 61 74 69 |ition of| "negati|
|00000c90| 76 65 22 20 77 69 74 68 | 20 70 6f 73 69 74 69 76 |ve" with| positiv|
|00000ca0| 65 20 70 69 78 65 6c 73 | 20 74 6f 20 70 72 6f 64 |e pixels| to prod|
|00000cb0| 75 63 65 20 70 6f 73 69 | 74 69 76 65 0d 70 69 78 |uce posi|tive.pix|
|00000cc0| 65 6c 73 20 77 69 6c 6c | 20 22 6f 76 65 72 66 6c |els will| "overfl|
|00000cd0| 6f 77 22 20 69 6e 20 74 | 68 65 20 6e 6f 72 6d 61 |ow" in t|he norma|
|00000ce0| 6c 20 63 6f 75 72 73 65 | 20 6f 66 20 63 6f 6d 70 |l course| of comp|
|00000cf0| 75 74 69 6e 67 20 74 68 | 65 20 73 75 6d 20 75 73 |uting th|e sum us|
|00000d00| 69 6e 67 20 75 6e 73 69 | 67 6e 65 64 0d 61 72 69 |ing unsi|gned.ari|
|00000d10| 74 68 6d 65 74 69 63 2e | 20 54 68 65 20 62 69 74 |thmetic.| The bit|
|00000d20| 73 20 6f 66 20 74 68 65 | 20 70 69 78 65 6c 20 69 |s of the| pixel i|
|00000d30| 74 73 65 6c 66 20 77 69 | 6c 6c 20 62 65 20 63 6f |tself wi|ll be co|
|00000d40| 72 72 65 63 74 2c 20 62 | 75 74 20 74 68 65 20 6f |rrect, b|ut the o|
|00000d50| 76 65 72 66 6c 6f 77 20 | 77 6f 75 6c 64 0d 61 66 |verflow |would.af|
|00000d60| 66 65 63 74 20 61 20 6e | 65 69 67 68 62 6f 72 69 |fect a n|eighbori|
|00000d70| 6e 67 20 70 69 78 65 6c | 20 69 66 20 70 61 72 61 |ng pixel| if para|
|00000d80| 6c 6c 65 6c 20 61 64 64 | 69 74 69 6f 6e 20 77 65 |llel add|ition we|
|00000d90| 72 65 20 75 73 65 64 2c | 20 73 6f 20 74 68 65 20 |re used,| so the |
|00000da0| 61 64 64 69 74 69 6f 6e | 73 20 61 72 65 0d 64 6f |addition|s are.do|
|00000db0| 6e 65 20 69 6e 64 65 70 | 65 6e 64 65 6e 74 6c 79 |ne indep|endently|
|00000dc0| 2c 20 6f 6e 65 20 70 69 | 78 65 6c 20 61 74 20 61 |, one pi|xel at a|
|00000dd0| 20 74 69 6d 65 2c 20 77 | 68 69 63 68 20 74 61 6b | time, w|hich tak|
|00000de0| 65 73 20 6c 6f 6e 67 65 | 72 2e 0d 0d 6b 42 69 6e |es longe|r...kBin|
|00000df0| 61 72 79 50 64 66 2c 20 | 6b 55 6e 69 66 6f 72 6d |aryPdf, |kUniform|
|00000e00| 50 64 66 2c 20 61 6e 64 | 20 6b 47 61 75 73 73 69 |Pdf, and| kGaussi|
|00000e10| 61 6e 50 64 66 20 73 68 | 6f 75 6c 64 20 61 6c 6c |anPdf sh|ould all|
|00000e20| 20 62 65 20 75 73 65 66 | 75 6c 2e 20 57 65 20 75 | be usef|ul. We u|
|00000e30| 73 65 0d 6b 47 61 75 73 | 73 69 61 6e 50 64 66 20 |se.kGaus|sianPdf |
|00000e40| 69 6e 20 6d 6f 73 74 20 | 6f 66 20 6f 75 72 20 6e |in most |of our n|
|00000e50| 6f 69 73 65 2d 6d 61 73 | 6b 69 6e 67 20 77 6f 72 |oise-mas|king wor|
|00000e60| 6b 2c 20 62 75 74 20 66 | 6f 72 20 64 79 6e 61 6d |k, but f|or dynam|
|00000e70| 69 63 20 6e 6f 69 73 65 | 20 77 65 0d 73 6f 6d 65 |ic noise| we.some|
|00000e80| 74 69 6d 65 73 20 75 73 | 65 20 6b 42 69 6e 61 72 |times us|e kBinar|
|00000e90| 79 50 64 66 20 69 6e 20 | 6f 72 64 65 72 20 74 6f |yPdf in |order to|
|00000ea0| 20 61 63 68 69 65 76 65 | 20 6d 6f 72 65 20 6e 6f | achieve| more no|
|00000eb0| 69 73 65 20 70 6f 77 65 | 72 2c 20 61 73 73 75 6d |ise powe|r, assum|
|00000ec0| 69 6e 67 20 74 68 61 74 | 20 74 68 65 0d 6f 62 73 |ing that| the.obs|
|00000ed0| 65 72 76 65 72 20 77 69 | 6c 6c 20 76 69 73 75 61 |erver wi|ll visua|
|00000ee0| 6c 6c 79 20 69 6e 74 65 | 67 72 61 74 65 20 73 65 |lly inte|grate se|
|00000ef0| 76 65 72 61 6c 20 6f 66 | 20 74 68 65 20 64 79 6e |veral of| the dyn|
|00000f00| 61 6d 69 63 20 66 72 61 | 6d 65 73 2c 20 62 6c 75 |amic fra|mes, blu|
|00000f10| 72 72 69 6e 67 20 74 68 | 65 0d 64 69 73 74 69 6e |rring th|e.distin|
|00000f20| 63 74 69 6f 6e 20 62 65 | 74 77 65 65 6e 20 70 64 |ction be|tween pd|
|00000f30| 66 27 73 2e 20 50 72 65 | 73 75 6d 61 62 6c 79 20 |f's. Pre|sumably |
|00000f40| 74 68 65 20 74 68 72 65 | 65 20 6b 69 6e 64 73 20 |the thre|e kinds |
|00000f50| 6f 66 20 6e 6f 69 73 65 | 20 77 6f 75 6c 64 20 62 |of noise| would b|
|00000f60| 65 20 76 69 73 75 61 6c | 6c 79 0d 69 6e 64 69 73 |e visual|ly.indis|
|00000f70| 74 69 6e 67 75 69 73 68 | 61 62 6c 65 20 69 66 20 |tinguish|able if |
|00000f80| 73 68 6f 77 6e 20 77 69 | 74 68 20 69 6e 64 65 70 |shown wi|th indep|
|00000f90| 65 6e 64 65 6e 74 20 31 | 35 20 6d 73 20 66 72 61 |endent 1|5 ms fra|
|00000fa0| 6d 65 73 20 61 6e 64 20 | 65 71 75 61 6c 20 73 64 |mes and |equal sd|
|00000fb0| 2e 0d 0d 6b 42 69 6e 6f | 6d 69 61 6c 50 64 66 20 |...kBino|mialPdf |
|00000fc0| 77 6f 72 6b 73 20 66 69 | 6e 65 2c 20 62 75 74 20 |works fi|ne, but |
|00000fd0| 69 73 20 6e 6f 74 20 72 | 65 63 6f 6d 6d 65 6e 64 |is not r|ecommend|
|00000fe0| 65 64 2e 20 54 68 65 20 | 6b 42 69 6e 6f 6d 69 61 |ed. The |kBinomia|
|00000ff0| 6c 50 64 66 20 63 6f 64 | 65 20 75 73 65 73 20 74 |lPdf cod|e uses t|
|00001000| 68 65 0d 66 61 63 74 20 | 74 68 61 74 20 74 68 65 |he.fact |that the|
|00001010| 20 6e 75 6d 62 65 72 20 | 6f 66 20 68 65 61 64 73 | number |of heads|
|00001020| 20 69 6e 20 32 34 20 63 | 6f 69 6e 20 74 6f 73 73 | in 24 c|oin toss|
|00001030| 65 73 20 69 73 20 61 70 | 70 72 6f 78 69 6d 61 74 |es is ap|proximat|
|00001040| 65 6c 79 20 67 61 75 73 | 73 69 61 6e 2e 20 54 68 |ely gaus|sian. Th|
|00001050| 69 73 0d 63 6f 64 65 20 | 77 61 73 20 6f 72 69 67 |is.code |was orig|
|00001060| 69 6e 61 6c 6c 79 20 77 | 72 69 74 74 65 6e 20 61 |inally w|ritten a|
|00001070| 73 20 61 20 71 75 69 63 | 6b 20 77 61 79 20 74 6f |s a quic|k way to|
|00001080| 20 6d 61 6b 65 20 61 70 | 70 72 6f 78 69 6d 61 74 | make ap|proximat|
|00001090| 65 6c 79 20 67 61 75 73 | 73 69 61 6e 20 6e 6f 69 |ely gaus|sian noi|
|000010a0| 73 65 2e 0d 48 6f 77 65 | 76 65 72 2c 20 6b 42 69 |se..Howe|ver, kBi|
|000010b0| 6e 6f 6d 69 61 6c 50 64 | 66 20 69 73 20 70 72 6f |nomialPd|f is pro|
|000010c0| 62 61 62 6c 79 20 6d 75 | 63 68 20 73 6c 6f 77 65 |bably mu|ch slowe|
|000010d0| 72 20 74 68 61 6e 20 74 | 68 65 20 73 75 62 73 65 |r than t|he subse|
|000010e0| 71 75 65 6e 74 6c 79 20 | 77 72 69 74 74 65 6e 0d |quently |written.|
|000010f0| 6b 47 61 75 73 73 69 61 | 6e 50 64 66 2c 20 77 68 |kGaussia|nPdf, wh|
|00001100| 69 63 68 20 70 72 6f 76 | 69 64 65 73 20 73 61 6d |ich prov|ides sam|
|00001110| 70 6c 65 73 20 74 68 61 | 74 20 61 72 65 20 61 63 |ples tha|t are ac|
|00001120| 63 75 72 61 74 65 6c 79 | 20 67 61 75 73 73 69 61 |curately| gaussia|
|00001130| 6e 2e 0d 0d 76 6f 69 64 | 20 47 65 74 47 6f 6f 64 |n...void| GetGood|
|00001140| 4e 6f 69 73 65 50 64 66 | 42 6f 75 6e 64 73 28 70 |NoisePdf|Bounds(p|
|00001150| 64 66 4b 69 6e 64 2c 6d | 65 61 6e 2c 63 6c 69 70 |dfKind,m|ean,clip|
|00001160| 70 65 64 53 64 2c 26 75 | 6e 63 6c 69 70 70 65 64 |pedSd,&u|nclipped|
|00001170| 53 64 2c 26 6d 69 6e 2c | 26 6d 61 78 29 3b 0d 0d |Sd,&min,|&max);..|
|00001180| 47 65 74 47 6f 6f 64 4e | 6f 69 73 65 50 64 66 42 |GetGoodN|oisePdfB|
|00001190| 6f 75 6e 64 73 20 69 73 | 20 61 20 75 74 69 6c 69 |ounds is| a utili|
|000011a0| 74 79 20 72 6f 75 74 69 | 6e 65 20 74 68 61 74 20 |ty routi|ne that |
|000011b0| 68 65 6c 70 73 20 79 6f | 75 20 63 68 6f 6f 73 65 |helps yo|u choose|
|000011c0| 20 67 6f 6f 64 20 70 61 | 72 61 6d 65 74 65 72 73 | good pa|rameters|
|000011d0| 0d 77 69 74 68 20 77 68 | 69 63 68 20 74 6f 20 63 |.with wh|ich to c|
|000011e0| 61 6c 6c 20 4e 6f 69 73 | 65 50 64 66 46 69 6c 6c |all Nois|ePdfFill|
|000011f0| 20 6f 72 20 4e 6f 69 73 | 65 50 64 66 41 64 64 2e | or Nois|ePdfAdd.|
|00001200| 20 42 65 20 61 77 61 72 | 65 20 74 68 61 74 2c 20 | Be awar|e that, |
|00001210| 77 68 65 72 65 61 73 0d | 4e 6f 69 73 65 50 64 66 |whereas.|NoisePdf|
|00001220| 46 69 6c 6c 20 61 6e 64 | 20 4e 6f 69 73 65 50 64 |Fill and| NoisePd|
|00001230| 66 41 64 64 20 61 72 65 | 20 67 65 6e 65 72 61 6c |fAdd are| general|
|00001240| 2d 70 75 72 70 6f 73 65 | 2c 20 74 68 65 20 22 67 |-purpose|, the "g|
|00001250| 6f 6f 64 22 20 69 6e 20 | 74 68 65 20 6e 61 6d 65 |ood" in |the name|
|00001260| 0d 22 47 65 74 47 6f 6f | 64 4e 6f 69 73 65 50 64 |."GetGoo|dNoisePd|
|00001270| 66 42 6f 75 6e 64 73 22 | 20 69 6e 64 69 63 61 74 |fBounds"| indicat|
|00001280| 65 73 20 74 68 61 74 20 | 69 74 73 20 72 65 63 6f |es that |its reco|
|00001290| 6d 6d 65 6e 64 61 74 69 | 6f 6e 73 20 61 72 65 20 |mmendati|ons are |
|000012a0| 6e 6f 74 20 6e 65 63 65 | 73 73 61 72 69 6c 79 0d |not nece|ssarily.|
|000012b0| 62 65 73 74 2e 20 49 74 | 20 69 6e 63 6f 72 70 6f |best. It| incorpo|
|000012c0| 72 61 74 65 73 20 73 65 | 76 65 72 61 6c 20 72 65 |rates se|veral re|
|000012d0| 61 73 6f 6e 61 62 6c 65 | 20 62 75 74 20 73 6f 6d |asonable| but som|
|000012e0| 65 77 68 61 74 20 61 72 | 62 69 74 72 61 72 79 20 |ewhat ar|bitrary |
|000012f0| 61 73 73 75 6d 70 74 69 | 6f 6e 73 2c 20 65 2e 67 |assumpti|ons, e.g|
|00001300| 2e 0d 74 68 61 74 20 79 | 6f 75 27 64 20 6c 69 6b |..that y|ou'd lik|
|00001310| 65 20 74 6f 20 63 6c 69 | 70 20 79 6f 75 72 20 67 |e to cli|p your g|
|00001320| 61 75 73 73 69 61 6e 20 | 61 74 20 b1 32 20 73 64 |aussian |at .2 sd|
|00001330| 2c 20 61 6e 64 20 68 65 | 6c 70 73 20 79 6f 75 20 |, and he|lps you |
|00001340| 74 6f 20 63 68 6f 6f 73 | 65 20 61 20 67 6f 6f 64 |to choos|e a good|
|00001350| 0d 73 65 74 20 6f 66 20 | 70 61 72 61 6d 65 74 65 |.set of |paramete|
|00001360| 72 73 20 74 6f 20 6f 62 | 74 61 69 6e 20 74 68 61 |rs to ob|tain tha|
|00001370| 74 20 72 65 73 75 6c 74 | 2e 20 47 65 74 47 6f 6f |t result|. GetGoo|
|00001380| 64 4e 6f 69 73 65 50 64 | 66 42 6f 75 6e 64 73 20 |dNoisePd|fBounds |
|00001390| 77 69 6c 6c 20 6e 6f 74 | 20 62 65 0d 61 70 70 72 |will not| be.appr|
|000013a0| 6f 70 72 69 61 74 65 20 | 74 6f 20 61 6c 6c 20 75 |opriate |to all u|
|000013b0| 73 65 73 20 6f 66 20 4e | 6f 69 73 65 50 64 66 46 |ses of N|oisePdfF|
|000013c0| 69 6c 6c 20 61 6e 64 20 | 4e 6f 69 73 65 50 64 66 |ill and |NoisePdf|
|000013d0| 41 64 64 3b 20 79 6f 75 | 20 6d 61 79 20 77 61 6e |Add; you| may wan|
|000013e0| 74 20 74 6f 20 77 72 69 | 74 65 0d 79 6f 75 72 20 |t to wri|te.your |
|000013f0| 6f 77 6e 2e 20 4e 6f 74 | 65 3a 20 47 65 74 47 6f |own. Not|e: GetGo|
|00001400| 6f 64 4e 6f 69 73 65 50 | 64 66 42 6f 75 6e 64 73 |odNoiseP|dfBounds|
|00001410| 20 69 73 20 73 74 69 6c | 6c 20 75 6e 64 65 72 20 | is stil|l under |
|00001420| 64 65 76 65 6c 6f 70 6d | 65 6e 74 3b 20 49 20 68 |developm|ent; I h|
|00001430| 61 76 65 6e 27 74 20 79 | 65 74 0d 61 64 64 65 64 |aven't y|et.added|
|00001440| 20 69 74 73 20 70 72 6f | 74 6f 74 79 70 65 20 74 | its pro|totype t|
|00001450| 6f 20 56 69 64 65 6f 54 | 6f 6f 6c 62 6f 78 2e 68 |o VideoT|oolbox.h|
|00001460| 2e 0d 0d 54 68 65 20 68 | 61 72 64 65 73 74 20 70 |...The h|ardest p|
|00001470| 61 72 74 20 6f 66 20 77 | 72 69 74 69 6e 67 20 74 |art of w|riting t|
|00001480| 68 65 20 63 6f 64 65 20 | 69 6e 20 74 68 69 73 20 |he code |in this |
|00001490| 66 69 6c 65 20 77 61 73 | 20 66 69 67 75 72 69 6e |file was| figurin|
|000014a0| 67 20 6f 75 74 20 68 6f | 77 20 74 6f 0d 73 65 70 |g out ho|w to.sep|
|000014b0| 61 72 61 74 65 20 74 68 | 65 20 67 65 6e 65 72 61 |arate th|e genera|
|000014c0| 6c 2d 70 75 72 70 6f 73 | 65 20 63 6f 64 65 20 28 |l-purpos|e code (|
|000014d0| 69 2e 65 2e 20 4e 6f 69 | 73 65 50 64 66 46 69 6c |i.e. Noi|sePdfFil|
|000014e0| 6c 29 20 66 72 6f 6d 20 | 74 68 65 20 70 72 61 67 |l) from |the prag|
|000014f0| 6d 61 74 69 63 20 62 75 | 74 0d 73 6f 6d 65 77 68 |matic bu|t.somewh|
|00001500| 61 74 20 61 72 62 69 74 | 72 61 72 79 20 61 73 73 |at arbit|rary ass|
|00001510| 75 6d 70 74 69 6f 6e 73 | 20 6e 6f 77 20 65 6e 63 |umptions| now enc|
|00001520| 61 70 73 75 6c 61 74 65 | 64 20 69 6e 20 47 65 74 |apsulate|d in Get|
|00001530| 47 6f 6f 64 4e 6f 69 73 | 65 50 64 66 42 6f 75 6e |GoodNois|ePdfBoun|
|00001540| 64 73 2e 0d 0d 48 49 53 | 54 4f 52 59 3a 0d 33 2f |ds...HIS|TORY:.3/|
|00001550| 32 30 2f 39 35 20 64 67 | 70 20 77 72 6f 74 65 20 |20/95 dg|p wrote |
|00001560| 69 74 2c 20 62 61 73 65 | 64 20 6f 6e 20 6d 79 20 |it, base|d on my |
|00001570| 4d 61 6b 65 54 65 78 74 | 49 6e 4e 6f 69 73 65 57 |MakeText|InNoiseW|
|00001580| 6f 72 6c 64 2e 63 0d 34 | 2f 38 2f 39 35 20 64 67 |orld.c.4|/8/95 dg|
|00001590| 70 20 72 65 6d 6f 76 65 | 64 20 61 6e 79 20 61 73 |p remove|d any as|
|000015a0| 73 75 6d 70 74 69 6f 6e | 20 74 68 61 74 20 77 6f |sumption| that wo|
|000015b0| 72 6c 64 20 69 73 20 61 | 20 47 57 6f 72 6c 64 50 |rld is a| GWorldP|
|000015c0| 74 72 3b 20 69 74 20 63 | 61 6e 20 61 6c 73 6f 0d |tr; it c|an also.|
|000015d0| 62 65 20 61 20 43 57 69 | 6e 64 6f 77 50 74 72 20 |be a CWi|ndowPtr |
|000015e0| 6f 72 20 61 20 57 69 6e | 64 6f 77 50 74 72 2e 0d |or a Win|dowPtr..|
|000015f0| 34 2f 31 38 2f 39 35 20 | 64 67 70 20 66 69 78 65 |4/18/95 |dgp fixe|
|00001600| 64 20 65 72 72 6f 72 20 | 69 6e 20 4e 6f 69 73 65 |d error |in Noise|
|00001610| 50 64 66 41 64 64 3a 20 | 6d 65 61 6e 20 26 20 73 |PdfAdd: |mean & s|
|00001620| 64 20 77 65 72 65 20 73 | 77 61 70 70 65 64 2e 0d |d were s|wapped..|
|00001630| 2a 2f 0d 0d 23 69 6e 63 | 6c 75 64 65 20 22 56 69 |*/..#inc|lude "Vi|
|00001640| 64 65 6f 54 6f 6f 6c 62 | 6f 78 2e 68 22 0d 23 69 |deoToolb|ox.h".#i|
|00001650| 6e 63 6c 75 64 65 20 3c | 61 73 73 65 72 74 2e 68 |nclude <|assert.h|
|00001660| 3e 0d 23 69 6e 63 6c 75 | 64 65 20 3c 6d 61 74 68 |>.#inclu|de <math|
|00001670| 2e 68 3e 0d 4f 53 45 72 | 72 20 4e 6f 69 73 65 50 |.h>.OSEr|r NoiseP|
|00001680| 64 66 46 69 6c 6c 28 47 | 57 6f 72 6c 64 50 74 72 |dfFill(G|WorldPtr|
|00001690| 20 77 6f 72 6c 64 2c 52 | 65 63 74 20 2a 72 65 63 | world,R|ect *rec|
|000016a0| 74 50 74 72 0d 09 2c 69 | 6e 74 20 70 64 66 4b 69 |tPtr..,i|nt pdfKi|
|000016b0| 6e 64 2c 64 6f 75 62 6c | 65 20 2a 6d 65 61 6e 50 |nd,doubl|e *meanP|
|000016c0| 74 72 2c 64 6f 75 62 6c | 65 20 2a 73 64 50 74 72 |tr,doubl|e *sdPtr|
|000016d0| 2c 69 6e 74 20 6d 69 6e | 2c 69 6e 74 20 6d 61 78 |,int min|,int max|
|000016e0| 29 3b 0d 4f 53 45 72 72 | 20 4e 6f 69 73 65 50 64 |);.OSErr| NoisePd|
|000016f0| 66 41 64 64 28 47 57 6f | 72 6c 64 50 74 72 20 77 |fAdd(GWo|rldPtr w|
|00001700| 6f 72 6c 64 2c 52 65 63 | 74 20 2a 72 65 63 74 50 |orld,Rec|t *rectP|
|00001710| 74 72 0d 09 2c 69 6e 74 | 20 70 64 66 4b 69 6e 64 |tr..,int| pdfKind|
|00001720| 2c 64 6f 75 62 6c 65 20 | 2a 6d 65 61 6e 50 74 72 |,double |*meanPtr|
|00001730| 2c 64 6f 75 62 6c 65 20 | 2a 73 64 50 74 72 2c 69 |,double |*sdPtr,i|
|00001740| 6e 74 20 6d 69 6e 2c 69 | 6e 74 20 6d 61 78 29 3b |nt min,i|nt max);|
|00001750| 0d 76 6f 69 64 20 47 65 | 74 47 6f 6f 64 4e 6f 69 |.void Ge|tGoodNoi|
|00001760| 73 65 50 64 66 42 6f 75 | 6e 64 73 28 69 6e 74 20 |sePdfBou|nds(int |
|00001770| 70 64 66 4b 69 6e 64 2c | 64 6f 75 62 6c 65 20 6d |pdfKind,|double m|
|00001780| 65 61 6e 2c 64 6f 75 62 | 6c 65 20 63 6c 69 70 70 |ean,doub|le clipp|
|00001790| 65 64 53 64 0d 09 2c 64 | 6f 75 62 6c 65 20 2a 75 |edSd..,d|ouble *u|
|000017a0| 6e 63 6c 69 70 70 65 64 | 53 64 50 74 72 2c 69 6e |nclipped|SdPtr,in|
|000017b0| 74 20 2a 6d 69 6e 50 74 | 72 2c 69 6e 74 20 2a 6d |t *minPt|r,int *m|
|000017c0| 61 78 50 74 72 29 3b 0d | 0d 2f 2f 65 6e 75 6d 7b |axPtr);.|.//enum{|
|000017d0| 6b 42 69 6e 61 72 79 50 | 64 66 3d 30 2c 6b 42 69 |kBinaryP|df=0,kBi|
|000017e0| 6e 6f 6d 69 61 6c 50 64 | 66 2c 6b 47 61 75 73 73 |nomialPd|f,kGauss|
|000017f0| 69 61 6e 50 64 66 2c 6b | 55 6e 69 66 6f 72 6d 50 |ianPdf,k|UniformP|
|00001800| 64 66 7d 3b 20 2f 2f 20 | 69 6e 20 56 69 64 65 6f |df}; // |in Video|
|00001810| 54 6f 6f 6c 62 6f 78 2e | 68 0d 0d 23 75 6e 64 65 |Toolbox.|h..#unde|
|00001820| 66 20 4d 41 58 0d 23 75 | 6e 64 65 66 20 4d 49 4e |f MAX.#u|ndef MIN|
|00001830| 0d 23 64 65 66 69 6e 65 | 20 4d 41 58 28 61 2c 62 |.#define| MAX(a,b|
|00001840| 29 20 28 28 61 29 20 3e | 20 28 62 29 20 3f 20 28 |) ((a) >| (b) ? (|
|00001850| 61 29 20 3a 20 28 62 29 | 29 0d 23 64 65 66 69 6e |a) : (b)|).#defin|
|00001860| 65 20 4d 49 4e 28 61 2c | 62 29 20 28 28 61 29 20 |e MIN(a,|b) ((a) |
|00001870| 3c 20 28 62 29 20 3f 20 | 28 61 29 20 3a 20 28 62 |< (b) ? |(a) : (b|
|00001880| 29 29 0d 73 74 61 74 69 | 63 20 42 6f 6f 6c 65 61 |)).stati|c Boolea|
|00001890| 6e 20 64 69 61 67 6e 6f | 73 74 69 63 73 3d 30 3b |n diagno|stics=0;|
|000018a0| 0d 0d 4f 53 45 72 72 20 | 4e 6f 69 73 65 50 64 66 |..OSErr |NoisePdf|
|000018b0| 46 69 6c 6c 28 47 57 6f | 72 6c 64 50 74 72 20 77 |Fill(GWo|rldPtr w|
|000018c0| 6f 72 6c 64 2c 52 65 63 | 74 20 2a 72 65 63 74 50 |orld,Rec|t *rectP|
|000018d0| 74 72 0d 09 2c 69 6e 74 | 20 70 64 66 4b 69 6e 64 |tr..,int| pdfKind|
|000018e0| 2c 64 6f 75 62 6c 65 20 | 2a 6d 65 61 6e 50 74 72 |,double |*meanPtr|
|000018f0| 2c 64 6f 75 62 6c 65 20 | 2a 73 64 50 74 72 2c 69 |,double |*sdPtr,i|
|00001900| 6e 74 20 6d 69 6e 2c 69 | 6e 74 20 6d 61 78 29 0d |nt min,i|nt max).|
|00001910| 7b 0d 09 43 47 72 61 66 | 50 74 72 20 6f 6c 64 50 |{..CGraf|Ptr oldP|
|00001920| 6f 72 74 3b 0d 09 47 44 | 48 61 6e 64 6c 65 20 6f |ort;..GD|Handle o|
|00001930| 6c 64 44 65 76 69 63 65 | 3b 0d 20 20 20 20 69 6e |ldDevice|;. in|
|00001940| 74 20 65 72 72 6f 72 3d | 30 3b 0d 09 4f 53 45 72 |t error=|0;..OSEr|
|00001950| 72 20 6f 73 45 72 72 3d | 30 3b 0d 09 6c 6f 6e 67 |r osErr=|0;..long|
|00001960| 20 6e 3b 0d 09 69 6e 74 | 20 69 2c 6a 2c 78 2c 79 | n;..int| i,j,x,y|
|00001970| 3b 0d 09 6c 6f 6e 67 20 | 6c 6f 77 2c 68 69 67 68 |;..long |low,high|
|00001980| 2c 73 61 6d 70 6c 65 3b | 0d 20 20 20 20 64 6f 75 |,sample;|. dou|
|00001990| 62 6c 65 20 61 63 74 75 | 61 6c 4d 65 61 6e 2c 61 |ble actu|alMean,a|
|000019a0| 63 74 75 61 6c 53 64 3b | 09 2f 2f 20 6d 65 61 6e |ctualSd;|.// mean|
|000019b0| 20 61 6e 64 20 73 64 20 | 6f 66 20 70 72 6f 63 65 | and sd |of proce|
|000019c0| 73 73 20 74 68 61 74 20 | 67 65 6e 65 72 61 74 65 |ss that |generate|
|000019d0| 64 20 74 68 65 20 69 6d | 61 67 65 0d 09 6c 6f 6e |d the im|age..lon|
|000019e0| 67 20 61 63 74 75 61 6c | 4d 69 6e 2c 61 63 74 75 |g actual|Min,actu|
|000019f0| 61 6c 4d 61 78 3b 0d 09 | 69 6e 74 20 62 69 6e 6f |alMax;..|int bino|
|00001a00| 6d 69 61 6c 53 61 6d 70 | 6c 65 73 3b 0d 09 64 6f |mialSamp|les;..do|
|00001a10| 75 62 6c 65 20 62 69 6e | 6f 6d 69 61 6c 46 61 63 |uble bin|omialFac|
|00001a20| 74 6f 72 3b 0d 09 6c 6f | 6e 67 20 65 78 74 72 61 |tor;..lo|ng extra|
|00001a30| 53 61 6d 70 6c 65 73 3b | 0d 09 73 68 6f 72 74 20 |Samples;|..short |
|00001a40| 2a 64 69 73 74 72 69 62 | 75 74 69 6f 6e 3b 0d 09 |*distrib|ution;..|
|00001a50| 73 74 61 74 69 63 20 73 | 68 6f 72 74 20 2a 2a 64 |static s|hort **d|
|00001a60| 69 73 74 72 69 62 75 74 | 69 6f 6e 48 61 6e 64 6c |istribut|ionHandl|
|00001a70| 65 3d 4e 55 4c 4c 3b 0d | 09 73 74 61 74 69 63 20 |e=NULL;.|.static |
|00001a80| 6c 6f 6e 67 20 64 69 73 | 74 72 69 62 75 74 69 6f |long dis|tributio|
|00001a90| 6e 53 69 7a 65 3b 0d 09 | 73 74 61 74 69 63 20 64 |nSize;..|static d|
|00001aa0| 6f 75 62 6c 65 20 6c 6f | 77 53 61 76 65 2c 68 69 |ouble lo|wSave,hi|
|00001ab0| 67 68 53 61 76 65 2c 6d | 65 61 6e 53 61 76 65 2c |ghSave,m|eanSave,|
|00001ac0| 75 6e 63 6c 69 70 70 65 | 64 53 64 53 61 76 65 2c |unclippe|dSdSave,|
|00001ad0| 61 63 74 75 61 6c 53 64 | 53 61 76 65 3b 0d 09 64 |actualSd|Save;..d|
|00001ae0| 6f 75 62 6c 65 20 6d 65 | 61 6e 53 71 75 61 72 65 |ouble me|anSquare|
|00001af0| 2c 61 2c 61 61 3b 0d 09 | 52 47 42 43 6f 6c 6f 72 |,a,aa;..|RGBColor|
|00001b00| 20 72 67 62 3b 0d 09 47 | 44 48 61 6e 64 6c 65 20 | rgb;..G|DHandle |
|00001b10| 64 65 76 69 63 65 3b 0d | 09 69 6e 74 20 70 69 78 |device;.|.int pix|
|00001b20| 65 6c 53 69 7a 65 3b 0d | 20 20 20 20 73 74 61 74 |elSize;.| stat|
|00001b30| 69 63 20 63 6f 6e 73 74 | 20 52 47 42 43 6f 6c 6f |ic const| RGBColo|
|00001b40| 72 20 62 6c 61 63 6b 52 | 47 42 3d 7b 30 2c 30 2c |r blackR|GB={0,0,|
|00001b50| 30 7d 2c 77 68 69 74 65 | 52 47 42 3d 7b 30 78 46 |0},white|RGB={0xF|
|00001b60| 46 46 46 2c 30 78 46 46 | 46 46 2c 30 78 46 46 46 |FFF,0xFF|FF,0xFFF|
|00001b70| 46 7d 3b 0d 09 75 6e 73 | 69 67 6e 65 64 20 6c 6f |F};..uns|igned lo|
|00001b80| 6e 67 20 70 69 78 5b 32 | 30 34 38 5d 3b 0d 09 72 |ng pix[2|048];..r|
|00001b90| 65 67 69 73 74 65 72 20 | 6c 6f 6e 67 20 2a 70 4c |egister |long *pL|
|00001ba0| 3b 0d 09 0d 09 2f 2f 20 | 4d 61 6b 65 20 6e 6f 69 |;....// |Make noi|
|00001bb0| 73 65 2e 20 54 61 6b 65 | 73 20 33 30 30 20 6d 73 |se. Take|s 300 ms|
|00001bc0| 0d 09 61 73 73 65 72 74 | 28 53 74 61 63 6b 53 70 |..assert|(StackSp|
|00001bd0| 61 63 65 28 29 3e 34 30 | 30 30 29 3b 0d 09 61 73 |ace()>40|00);..as|
|00001be0| 73 65 72 74 28 77 6f 72 | 6c 64 21 3d 4e 55 4c 4c |sert(wor|ld!=NULL|
|00001bf0| 20 26 26 20 73 64 50 74 | 72 21 3d 4e 55 4c 4c 20 | && sdPt|r!=NULL |
|00001c00| 26 26 20 6d 65 61 6e 50 | 74 72 21 3d 4e 55 4c 4c |&& meanP|tr!=NULL|
|00001c10| 29 3b 0d 09 61 73 73 65 | 72 74 28 21 49 73 4e 61 |);..asse|rt(!IsNa|
|00001c20| 6e 28 2a 6d 65 61 6e 50 | 74 72 29 20 26 26 20 21 |n(*meanP|tr) && !|
|00001c30| 49 73 4e 61 6e 28 2a 73 | 64 50 74 72 29 29 3b 0d |IsNan(*s|dPtr));.|
|00001c40| 09 61 73 73 65 72 74 28 | 2a 73 64 50 74 72 3e 3d |.assert(|*sdPtr>=|
|00001c50| 30 2e 30 29 3b 0d 09 61 | 73 73 65 72 74 28 6d 69 |0.0);..a|ssert(mi|
|00001c60| 6e 3c 3d 2a 6d 65 61 6e | 50 74 72 20 26 26 20 2a |n<=*mean|Ptr && *|
|00001c70| 6d 65 61 6e 50 74 72 3c | 3d 6d 61 78 29 3b 0d 09 |meanPtr<|=max);..|
|00001c80| 68 69 67 68 3d 6d 61 78 | 3b 0d 09 6c 6f 77 3d 6d |high=max|;..low=m|
|00001c90| 69 6e 3b 0d 09 69 66 28 | 49 73 49 6e 66 28 2a 73 |in;..if(|IsInf(*s|
|00001ca0| 64 50 74 72 29 20 26 26 | 20 70 64 66 4b 69 6e 64 |dPtr) &&| pdfKind|
|00001cb0| 21 3d 6b 42 69 6e 61 72 | 79 50 64 66 29 70 64 66 |!=kBinar|yPdf)pdf|
|00001cc0| 4b 69 6e 64 3d 6b 55 6e | 69 66 6f 72 6d 50 64 66 |Kind=kUn|iformPdf|
|00001cd0| 3b 0d 09 73 77 69 74 63 | 68 28 70 64 66 4b 69 6e |;..switc|h(pdfKin|
|00001ce0| 64 29 7b 0d 09 63 61 73 | 65 20 6b 42 69 6e 61 72 |d){..cas|e kBinar|
|00001cf0| 79 50 64 66 3a 0d 09 09 | 2f 2f 20 68 69 67 68 20 |yPdf:...|// high |
|00001d00| 61 6e 64 20 6c 6f 77 20 | 61 72 65 20 76 61 6c 75 |and low |are valu|
|00001d10| 65 73 20 63 6f 72 72 65 | 73 70 6f 6e 64 69 6e 67 |es corre|sponding|
|00001d20| 20 74 6f 20 68 65 61 64 | 73 20 61 6e 64 20 74 61 | to head|s and ta|
|00001d30| 69 6c 73 2e 0d 09 09 2f | 2f 20 54 68 65 20 68 69 |ils..../|/ The hi|
|00001d40| 67 68 2d 6c 6f 77 20 64 | 69 66 66 65 72 65 6e 63 |gh-low d|ifferenc|
|00001d50| 65 20 69 73 20 6d 6f 72 | 65 20 69 6d 70 6f 72 74 |e is mor|e import|
|00001d60| 61 6e 74 20 74 68 61 6e | 20 74 68 65 69 72 20 69 |ant than| their i|
|00001d70| 6e 64 69 76 69 64 75 61 | 6c 20 76 61 6c 75 65 73 |ndividua|l values|
|00001d80| 2e 0d 09 09 69 66 28 21 | 49 73 49 6e 66 28 2a 73 |....if(!|IsInf(*s|
|00001d90| 64 50 74 72 29 29 7b 0d | 09 09 09 61 3d 32 2a 28 |dPtr)){.|...a=2*(|
|00001da0| 2a 73 64 50 74 72 29 3b | 0d 09 09 09 6c 6f 77 3d |*sdPtr);|....low=|
|00001db0| 4d 41 58 28 66 6c 6f 6f | 72 28 30 2e 35 2b 2a 6d |MAX(floo|r(0.5+*m|
|00001dc0| 65 61 6e 50 74 72 2d 61 | 2f 32 29 2c 6d 69 6e 29 |eanPtr-a|/2),min)|
|00001dd0| 3b 0d 09 09 09 68 69 67 | 68 3d 4d 49 4e 28 66 6c |;....hig|h=MIN(fl|
|00001de0| 6f 6f 72 28 30 2e 35 2b | 6c 6f 77 2b 61 29 2c 6d |oor(0.5+|low+a),m|
|00001df0| 61 78 29 3b 0d 09 09 09 | 6c 6f 77 3d 4d 41 58 28 |ax);....|low=MAX(|
|00001e00| 66 6c 6f 6f 72 28 30 2e | 35 2b 68 69 67 68 2d 61 |floor(0.|5+high-a|
|00001e10| 29 2c 6d 69 6e 29 3b 0d | 09 09 09 69 66 28 6c 6f |),min);.|...if(lo|
|00001e20| 77 3d 3d 68 69 67 68 20 | 26 26 20 2a 73 64 50 74 |w==high |&& *sdPt|
|00001e30| 72 3e 30 29 7b 0d 09 09 | 09 09 69 66 28 68 69 67 |r>0){...|..if(hig|
|00001e40| 68 3c 6d 61 78 29 68 69 | 67 68 2b 2b 3b 0d 09 09 |h<max)hi|gh++;...|
|00001e50| 09 09 65 6c 73 65 20 69 | 66 28 6c 6f 77 3e 6d 69 |..else i|f(low>mi|
|00001e60| 6e 29 6c 6f 77 2d 2d 3b | 0d 09 09 09 7d 0d 09 09 |n)low--;|....}...|
|00001e70| 7d 0d 09 09 62 72 65 61 | 6b 3b 0d 09 63 61 73 65 |}...brea|k;..case|
|00001e80| 20 6b 55 6e 69 66 6f 72 | 6d 50 64 66 3a 0d 09 09 | kUnifor|mPdf:...|
|00001e90| 69 66 28 21 49 73 49 6e | 66 28 2a 73 64 50 74 72 |if(!IsIn|f(*sdPtr|
|00001ea0| 29 29 7b 0d 09 09 09 61 | 3d 32 2a 73 71 72 74 28 |)){....a|=2*sqrt(|
|00001eb0| 33 29 2a 28 2a 73 64 50 | 74 72 29 2d 31 3b 09 2f |3)*(*sdP|tr)-1;./|
|00001ec0| 2f 20 69 6e 74 65 67 65 | 72 20 72 61 6e 67 65 20 |/ intege|r range |
|00001ed0| 6f 66 20 70 64 66 20 66 | 6f 72 20 73 70 65 63 69 |of pdf f|or speci|
|00001ee0| 66 69 65 64 20 73 64 0d | 09 09 09 6c 6f 77 3d 4d |fied sd.|...low=M|
|00001ef0| 41 58 28 66 6c 6f 6f 72 | 28 30 2e 35 2b 2a 6d 65 |AX(floor|(0.5+*me|
|00001f00| 61 6e 50 74 72 2d 61 2f | 32 29 2c 6d 69 6e 29 3b |anPtr-a/|2),min);|
|00001f10| 0d 09 09 09 68 69 67 68 | 3d 4d 49 4e 28 66 6c 6f |....high|=MIN(flo|
|00001f20| 6f 72 28 30 2e 35 2b 6c | 6f 77 2b 61 29 2c 6d 61 |or(0.5+l|ow+a),ma|
|00001f30| 78 29 3b 0d 09 09 09 6c | 6f 77 3d 4d 41 58 28 66 |x);....l|ow=MAX(f|
|00001f40| 6c 6f 6f 72 28 30 2e 35 | 2b 68 69 67 68 2d 61 29 |loor(0.5|+high-a)|
|00001f50| 2c 6d 69 6e 29 3b 0d 09 | 09 09 69 66 28 6c 6f 77 |,min);..|..if(low|
|00001f60| 3d 3d 68 69 67 68 20 26 | 26 20 2a 73 64 50 74 72 |==high &|& *sdPtr|
|00001f70| 3e 30 29 7b 0d 09 09 09 | 09 69 66 28 68 69 67 68 |>0){....|.if(high|
|00001f80| 3c 6d 61 78 29 68 69 67 | 68 2b 2b 3b 0d 09 09 09 |<max)hig|h++;....|
|00001f90| 09 65 6c 73 65 20 69 66 | 28 6c 6f 77 3e 6d 69 6e |.else if|(low>min|
|00001fa0| 29 6c 6f 77 2d 2d 3b 0d | 09 09 09 7d 0d 09 09 7d |)low--;.|...}...}|
|00001fb0| 0d 09 09 62 72 65 61 6b | 3b 0d 09 64 65 66 61 75 |...break|;..defau|
|00001fc0| 6c 74 3a 0d 09 09 62 72 | 65 61 6b 3b 0d 09 7d 0d |lt:...br|eak;..}.|
|00001fd0| 09 47 65 74 47 57 6f 72 | 6c 64 28 26 6f 6c 64 50 |.GetGWor|ld(&oldP|
|00001fe0| 6f 72 74 2c 26 6f 6c 64 | 44 65 76 69 63 65 29 3b |ort,&old|Device);|
|00001ff0| 0d 09 64 65 76 69 63 65 | 3d 47 65 74 57 69 6e 64 |..device|=GetWind|
|00002000| 6f 77 44 65 76 69 63 65 | 28 28 57 69 6e 64 6f 77 |owDevice|((Window|
|00002010| 50 74 72 29 77 6f 72 6c | 64 29 3b 0d 09 70 69 78 |Ptr)worl|d);..pix|
|00002020| 65 6c 53 69 7a 65 3d 28 | 2a 2a 28 2a 2a 64 65 76 |elSize=(|**(**dev|
|00002030| 69 63 65 29 2e 67 64 50 | 4d 61 70 29 2e 70 69 78 |ice).gdP|Map).pix|
|00002040| 65 6c 53 69 7a 65 3b 0d | 09 69 66 28 6c 6f 77 3d |elSize;.|.if(low=|
|00002050| 3d 68 69 67 68 29 7b 0d | 09 09 53 65 74 47 57 6f |=high){.|..SetGWo|
|00002060| 72 6c 64 28 77 6f 72 6c | 64 2c 64 65 76 69 63 65 |rld(worl|d,device|
|00002070| 29 3b 0d 09 09 49 6e 64 | 65 78 32 43 6f 6c 6f 72 |);...Ind|ex2Color|
|00002080| 28 6c 6f 77 2c 26 72 67 | 62 29 3b 0d 09 09 52 47 |(low,&rg|b);...RG|
|00002090| 42 42 61 63 6b 43 6f 6c | 6f 72 28 26 72 67 62 29 |BBackCol|or(&rgb)|
|000020a0| 3b 0d 09 09 45 72 61 73 | 65 52 65 63 74 28 72 65 |;...Eras|eRect(re|
|000020b0| 63 74 50 74 72 29 3b 0d | 09 09 53 65 74 47 57 6f |ctPtr);.|..SetGWo|
|000020c0| 72 6c 64 28 6f 6c 64 50 | 6f 72 74 2c 6f 6c 64 44 |rld(oldP|ort,oldD|
|000020d0| 65 76 69 63 65 29 3b 0d | 09 09 61 63 74 75 61 6c |evice);.|..actual|
|000020e0| 4d 65 61 6e 3d 6c 6f 77 | 3b 0d 09 09 61 63 74 75 |Mean=low|;...actu|
|000020f0| 61 6c 53 64 3d 30 3b 0d | 09 09 67 6f 74 6f 20 64 |alSd=0;.|..goto d|
|00002100| 6f 6e 65 3b 0d 09 7d 0d | 09 73 77 69 74 63 68 28 |one;..}.|.switch(|
|00002110| 70 64 66 4b 69 6e 64 29 | 7b 0d 09 63 61 73 65 20 |pdfKind)|{..case |
|00002120| 6b 42 69 6e 61 72 79 50 | 64 66 3a 0d 09 09 53 65 |kBinaryP|df:...Se|
|00002130| 74 47 57 6f 72 6c 64 28 | 77 6f 72 6c 64 2c 64 65 |tGWorld(|world,de|
|00002140| 76 69 63 65 29 3b 0d 09 | 09 49 6e 64 65 78 32 43 |vice);..|.Index2C|
|00002150| 6f 6c 6f 72 28 6c 6f 77 | 2c 26 72 67 62 29 3b 0d |olor(low|,&rgb);.|
|00002160| 09 09 52 47 42 42 61 63 | 6b 43 6f 6c 6f 72 28 26 |..RGBBac|kColor(&|
|00002170| 72 67 62 29 3b 0d 09 09 | 49 6e 64 65 78 32 43 6f |rgb);...|Index2Co|
|00002180| 6c 6f 72 28 68 69 67 68 | 2c 26 72 67 62 29 3b 0d |lor(high|,&rgb);.|
|00002190| 09 09 52 47 42 46 6f 72 | 65 43 6f 6c 6f 72 28 26 |..RGBFor|eColor(&|
|000021a0| 72 67 62 29 3b 0d 09 09 | 65 72 72 6f 72 3d 4e 6f |rgb);...|error=No|
|000021b0| 69 73 65 46 69 6c 6c 28 | 77 6f 72 6c 64 2c 72 65 |iseFill(|world,re|
|000021c0| 63 74 50 74 72 2c 31 2c | 31 2c 30 29 3b 20 0d 09 |ctPtr,1,|1,0); ..|
|000021d0| 09 52 47 42 42 61 63 6b | 43 6f 6c 6f 72 28 26 77 |.RGBBack|Color(&w|
|000021e0| 68 69 74 65 52 47 42 29 | 3b 0d 09 09 52 47 42 46 |hiteRGB)|;...RGBF|
|000021f0| 6f 72 65 43 6f 6c 6f 72 | 28 26 62 6c 61 63 6b 52 |oreColor|(&blackR|
|00002200| 47 42 29 3b 0d 09 09 53 | 65 74 47 57 6f 72 6c 64 |GB);...S|etGWorld|
|00002210| 28 6f 6c 64 50 6f 72 74 | 2c 6f 6c 64 44 65 76 69 |(oldPort|,oldDevi|
|00002220| 63 65 29 3b 0d 09 09 61 | 63 74 75 61 6c 53 64 3d |ce);...a|ctualSd=|
|00002230| 30 2e 35 2a 28 68 69 67 | 68 2d 6c 6f 77 29 3b 0d |0.5*(hig|h-low);.|
|00002240| 09 09 61 63 74 75 61 6c | 4d 65 61 6e 3d 30 2e 35 |..actual|Mean=0.5|
|00002250| 2a 28 68 69 67 68 2b 6c | 6f 77 29 3b 0d 09 09 62 |*(high+l|ow);...b|
|00002260| 72 65 61 6b 3b 0d 09 63 | 61 73 65 20 6b 55 6e 69 |reak;..c|ase kUni|
|00002270| 66 6f 72 6d 50 64 66 3a | 0d 09 09 6e 3d 31 2b 68 |formPdf:|...n=1+h|
|00002280| 69 67 68 2d 6c 6f 77 3b | 0d 09 09 61 73 73 65 72 |igh-low;|...asser|
|00002290| 74 28 72 65 63 74 50 74 | 72 2d 3e 72 69 67 68 74 |t(rectPt|r->right|
|000022a0| 2d 72 65 63 74 50 74 72 | 2d 3e 6c 65 66 74 3c 3d |-rectPtr|->left<=|
|000022b0| 73 69 7a 65 6f 66 28 70 | 69 78 29 2f 73 69 7a 65 |sizeof(p|ix)/size|
|000022c0| 6f 66 28 2a 70 69 78 29 | 29 3b 0d 09 09 66 6f 72 |of(*pix)|);...for|
|000022d0| 28 79 3d 72 65 63 74 50 | 74 72 2d 3e 74 6f 70 3b |(y=rectP|tr->top;|
|000022e0| 79 3c 72 65 63 74 50 74 | 72 2d 3e 62 6f 74 74 6f |y<rectPt|r->botto|
|000022f0| 6d 3b 79 2b 2b 29 7b 0d | 09 09 09 70 4c 3d 28 6c |m;y++){.|...pL=(l|
|00002300| 6f 6e 67 20 2a 29 70 69 | 78 3b 0d 09 09 09 66 6f |ong *)pi|x;....fo|
|00002310| 72 28 78 3d 72 65 63 74 | 50 74 72 2d 3e 72 69 67 |r(x=rect|Ptr->rig|
|00002320| 68 74 2d 72 65 63 74 50 | 74 72 2d 3e 6c 65 66 74 |ht-rectP|tr->left|
|00002330| 2d 31 3b 78 3e 3d 30 3b | 78 2d 2d 29 0d 09 09 09 |-1;x>=0;|x--)....|
|00002340| 09 2a 70 4c 2b 2b 3d 6c | 6f 77 2b 6e 72 61 6e 64 |.*pL++=l|ow+nrand|
|00002350| 28 6e 29 3b 0d 09 09 09 | 53 65 74 57 69 6e 64 6f |(n);....|SetWindo|
|00002360| 77 50 69 78 65 6c 73 51 | 75 69 63 6b 6c 79 28 28 |wPixelsQ|uickly((|
|00002370| 57 69 6e 64 6f 77 50 74 | 72 29 77 6f 72 6c 64 2c |WindowPt|r)world,|
|00002380| 72 65 63 74 50 74 72 2d | 3e 6c 65 66 74 2c 79 0d |rectPtr-|>left,y.|
|00002390| 09 09 09 09 2c 70 69 78 | 2c 72 65 63 74 50 74 72 |....,pix|,rectPtr|
|000023a0| 2d 3e 72 69 67 68 74 2d | 72 65 63 74 50 74 72 2d |->right-|rectPtr-|
|000023b0| 3e 6c 65 66 74 29 3b 0d | 09 09 7d 0d 09 09 61 73 |>left);.|..}...as|
|000023c0| 73 65 72 74 28 6e 3c 3d | 73 69 7a 65 6f 66 28 70 |sert(n<=|sizeof(p|
|000023d0| 69 78 29 2f 73 69 7a 65 | 6f 66 28 2a 70 4c 29 29 |ix)/size|of(*pL))|
|000023e0| 3b 0d 09 09 70 4c 3d 28 | 6c 6f 6e 67 20 2a 29 70 |;...pL=(|long *)p|
|000023f0| 69 78 3b 0d 09 09 66 6f | 72 28 78 3d 6c 6f 77 3b |ix;...fo|r(x=low;|
|00002400| 78 3c 3d 68 69 67 68 3b | 78 2b 2b 29 2a 70 4c 2b |x<=high;|x++)*pL+|
|00002410| 2b 3d 78 3b 0d 09 09 61 | 63 74 75 61 6c 4d 65 61 |+=x;...a|ctualMea|
|00002420| 6e 3d 4d 65 61 6e 4c 28 | 28 6c 6f 6e 67 20 2a 29 |n=MeanL(|(long *)|
|00002430| 70 69 78 2c 31 2b 68 69 | 67 68 2d 6c 6f 77 2c 26 |pix,1+hi|gh-low,&|
|00002440| 61 63 74 75 61 6c 53 64 | 29 3b 0d 09 09 69 66 28 |actualSd|);...if(|
|00002450| 64 69 61 67 6e 6f 73 74 | 69 63 73 29 70 72 69 6e |diagnost|ics)prin|
|00002460| 74 66 28 22 75 6e 63 6c | 69 70 70 65 64 53 64 20 |tf("uncl|ippedSd |
|00002470| 25 66 2c 20 61 63 74 75 | 61 6c 53 64 20 25 66 2c |%f, actu|alSd %f,|
|00002480| 20 61 63 74 75 61 6c 53 | 64 2f 75 6e 63 6c 69 70 | actualS|d/unclip|
|00002490| 70 65 64 53 64 20 25 66 | 5c 6e 22 0d 09 09 09 2c |pedSd %f|\n"....,|
|000024a0| 2a 73 64 50 74 72 2c 61 | 63 74 75 61 6c 53 64 2c |*sdPtr,a|ctualSd,|
|000024b0| 61 63 74 75 61 6c 53 64 | 2f 28 2a 73 64 50 74 72 |actualSd|/(*sdPtr|
|000024c0| 29 29 3b 0d 09 09 62 72 | 65 61 6b 3b 0d 09 63 61 |));...br|eak;..ca|
|000024d0| 73 65 20 6b 47 61 75 73 | 73 69 61 6e 50 64 66 3a |se kGaus|sianPdf:|
|000024e0| 0d 09 09 2f 2a 0d 09 09 | 46 69 72 73 74 20 77 65 |.../*...|First we|
|000024f0| 20 6d 61 6b 65 20 61 6e | 20 6f 72 64 65 72 65 64 | make an| ordered|
|00002500| 20 6c 69 73 74 20 6f 66 | 20 61 62 6f 75 74 20 74 | list of| about t|
|00002510| 77 65 6e 74 79 20 74 68 | 6f 75 73 61 6e 64 20 69 |wenty th|ousand i|
|00002520| 6e 74 65 67 65 72 73 2c | 20 77 69 74 68 20 0d 09 |ntegers,| with ..|
|00002530| 09 66 72 65 71 75 65 6e | 63 79 20 70 72 6f 70 6f |.frequen|cy propo|
|00002540| 72 74 69 6f 6e 61 6c 20 | 74 6f 20 74 68 65 20 64 |rtional |to the d|
|00002550| 65 73 69 72 65 64 20 70 | 72 6f 62 61 62 69 6c 69 |esired p|robabili|
|00002560| 74 79 2e 20 54 68 69 73 | 20 74 61 62 6c 65 20 6f |ty. This| table o|
|00002570| 6e 6c 79 20 6e 65 65 64 | 73 0d 09 09 74 6f 20 62 |nly need|s...to b|
|00002580| 65 20 6d 61 64 65 20 6f | 6e 63 65 20 61 6e 64 20 |e made o|nce and |
|00002590| 63 61 6e 20 62 65 20 72 | 65 75 73 65 64 20 69 6e |can be r|eused in|
|000025a0| 64 65 66 69 6e 69 74 65 | 6c 79 2c 20 75 6e 74 69 |definite|ly, unti|
|000025b0| 6c 20 74 68 65 20 70 61 | 72 61 6d 65 74 65 72 73 |l the pa|rameters|
|000025c0| 20 20 0d 09 09 28 6d 65 | 61 6e 2c 20 73 64 2c 20 | ...(me|an, sd, |
|000025d0| 6d 69 6e 2c 20 6d 61 78 | 29 20 6f 66 20 74 68 65 |min, max|) of the|
|000025e0| 20 64 69 73 74 72 69 62 | 75 74 69 6f 6e 20 63 68 | distrib|ution ch|
|000025f0| 61 6e 67 65 2e 20 45 61 | 63 68 20 6e 6f 69 73 65 |ange. Ea|ch noise|
|00002600| 20 70 69 78 65 6c 20 69 | 73 0d 09 09 61 20 72 61 | pixel i|s...a ra|
|00002610| 6e 64 6f 6d 20 73 61 6d | 70 6c 65 20 66 72 6f 6d |ndom sam|ple from|
|00002620| 20 74 68 65 20 74 61 62 | 6c 65 2e 0d 09 09 2a 2f | the tab|le....*/|
|00002630| 0d 09 09 69 66 28 64 69 | 73 74 72 69 62 75 74 69 |...if(di|stributi|
|00002640| 6f 6e 48 61 6e 64 6c 65 | 3d 3d 4e 55 4c 4c 20 7c |onHandle|==NULL ||
|00002650| 7c 20 6c 6f 77 21 3d 6c | 6f 77 53 61 76 65 20 7c || low!=l|owSave ||
|00002660| 7c 20 68 69 67 68 21 3d | 68 69 67 68 53 61 76 65 || high!=|highSave|
|00002670| 20 0d 09 09 09 7c 7c 20 | 49 73 49 6e 66 28 2a 73 | ....|| |IsInf(*s|
|00002680| 64 50 74 72 29 21 3d 49 | 73 49 6e 66 28 75 6e 63 |dPtr)!=I|sInf(unc|
|00002690| 6c 69 70 70 65 64 53 64 | 53 61 76 65 29 0d 09 09 |lippedSd|Save)...|
|000026a0| 09 7c 7c 20 28 21 49 73 | 49 6e 66 28 2a 73 64 50 |.|| (!Is|Inf(*sdP|
|000026b0| 74 72 29 20 26 26 20 66 | 61 62 73 28 2a 73 64 50 |tr) && f|abs(*sdP|
|000026c0| 74 72 2f 75 6e 63 6c 69 | 70 70 65 64 53 64 53 61 |tr/uncli|ppedSdSa|
|000026d0| 76 65 2d 31 29 3e 2e 30 | 31 29 0d 09 09 09 7c 7c |ve-1)>.0|1)....|||
|000026e0| 20 2a 6d 65 61 6e 50 74 | 72 21 3d 6d 65 61 6e 53 | *meanPt|r!=meanS|
|000026f0| 61 76 65 29 7b 0d 09 09 | 09 64 69 73 74 72 69 62 |ave){...|.distrib|
|00002700| 75 74 69 6f 6e 53 69 7a | 65 3d 32 35 36 2a 31 30 |utionSiz|e=256*10|
|00002710| 30 4c 3b 0d 09 09 09 69 | 66 28 64 69 73 74 72 69 |0L;....i|f(distri|
|00002720| 62 75 74 69 6f 6e 48 61 | 6e 64 6c 65 3d 3d 4e 55 |butionHa|ndle==NU|
|00002730| 4c 4c 29 7b 0d 09 09 09 | 09 64 69 73 74 72 69 62 |LL){....|.distrib|
|00002740| 75 74 69 6f 6e 48 61 6e | 64 6c 65 3d 28 73 68 6f |utionHan|dle=(sho|
|00002750| 72 74 20 2a 2a 29 54 65 | 6d 70 4e 65 77 48 61 6e |rt **)Te|mpNewHan|
|00002760| 64 6c 65 28 64 69 73 74 | 72 69 62 75 74 69 6f 6e |dle(dist|ribution|
|00002770| 53 69 7a 65 2a 73 69 7a | 65 6f 66 28 2a 64 69 73 |Size*siz|eof(*dis|
|00002780| 74 72 69 62 75 74 69 6f | 6e 29 2c 26 6f 73 45 72 |tributio|n),&osEr|
|00002790| 72 29 3b 0d 09 09 09 09 | 65 72 72 6f 72 3d 6f 73 |r);.....|error=os|
|000027a0| 45 72 72 3b 0d 09 09 09 | 09 69 66 28 64 69 73 74 |Err;....|.if(dist|
|000027b0| 72 69 62 75 74 69 6f 6e | 48 61 6e 64 6c 65 3d 3d |ribution|Handle==|
|000027c0| 4e 55 4c 4c 29 7b 0d 09 | 09 09 09 09 64 69 73 74 |NULL){..|....dist|
|000027d0| 72 69 62 75 74 69 6f 6e | 48 61 6e 64 6c 65 3d 28 |ribution|Handle=(|
|000027e0| 73 68 6f 72 74 20 2a 2a | 29 4e 65 77 48 61 6e 64 |short **|)NewHand|
|000027f0| 6c 65 28 64 69 73 74 72 | 69 62 75 74 69 6f 6e 53 |le(distr|ibutionS|
|00002800| 69 7a 65 2a 73 69 7a 65 | 6f 66 28 2a 64 69 73 74 |ize*size|of(*dist|
|00002810| 72 69 62 75 74 69 6f 6e | 29 29 3b 0d 09 09 09 09 |ribution|));.....|
|00002820| 09 65 72 72 6f 72 3d 4d | 65 6d 45 72 72 6f 72 28 |.error=M|emError(|
|00002830| 29 3b 0d 09 09 09 09 7d | 65 6c 73 65 20 65 72 72 |);.....}|else err|
|00002840| 6f 72 3d 30 3b 0d 09 09 | 09 09 69 66 28 64 69 73 |or=0;...|..if(dis|
|00002850| 74 72 69 62 75 74 69 6f | 6e 48 61 6e 64 6c 65 3d |tributio|nHandle=|
|00002860| 3d 4e 55 4c 4c 29 50 72 | 69 6e 74 66 45 78 69 74 |=NULL)Pr|intfExit|
|00002870| 28 22 53 6f 72 72 79 2c | 20 63 6f 75 6c 64 6e 27 |("Sorry,| couldn'|
|00002880| 74 20 61 6c 6c 6f 63 61 | 74 65 20 25 6c 64 20 62 |t alloca|te %ld b|
|00002890| 79 74 65 73 20 22 0d 09 | 09 09 09 09 22 66 6f 72 |ytes "..|...."for|
|000028a0| 20 61 20 67 61 75 73 73 | 69 61 6e 20 74 61 62 6c | a gauss|ian tabl|
|000028b0| 65 2e 20 46 69 6c 65 20 | d2 25 73 d3 20 6c 69 6e |e. File |.%s. lin|
|000028c0| 65 20 25 64 2e 5c 6e 22 | 0d 09 09 09 09 09 2c 64 |e %d.\n"|......,d|
|000028d0| 69 73 74 72 69 62 75 74 | 69 6f 6e 53 69 7a 65 2a |istribut|ionSize*|
|000028e0| 73 69 7a 65 6f 66 28 2a | 64 69 73 74 72 69 62 75 |sizeof(*|distribu|
|000028f0| 74 69 6f 6e 29 2c 5f 5f | 46 49 4c 45 5f 5f 2c 5f |tion),__|FILE__,_|
|00002900| 5f 4c 49 4e 45 5f 5f 29 | 3b 0d 09 09 09 7d 0d 09 |_LINE__)|;....}..|
|00002910| 09 09 69 66 28 66 61 62 | 73 28 28 68 69 67 68 2d |..if(fab|s((high-|
|00002920| 2a 6d 65 61 6e 50 74 72 | 29 2d 28 68 69 67 68 53 |*meanPtr|)-(highS|
|00002930| 61 76 65 2d 6d 65 61 6e | 53 61 76 65 29 29 3e 30 |ave-mean|Save))>0|
|00002940| 2e 35 20 7c 7c 20 68 69 | 67 68 2d 6c 6f 77 21 3d |.5 || hi|gh-low!=|
|00002950| 68 69 67 68 53 61 76 65 | 2d 6c 6f 77 53 61 76 65 |highSave|-lowSave|
|00002960| 20 0d 09 09 09 09 7c 7c | 20 49 73 49 6e 66 28 2a | .....||| IsInf(*|
|00002970| 73 64 50 74 72 29 21 3d | 49 73 49 6e 66 28 75 6e |sdPtr)!=|IsInf(un|
|00002980| 63 6c 69 70 70 65 64 53 | 64 53 61 76 65 29 0d 09 |clippedS|dSave)..|
|00002990| 09 09 09 7c 7c 20 28 21 | 49 73 49 6e 66 28 2a 73 |...|| (!|IsInf(*s|
|000029a0| 64 50 74 72 29 20 26 26 | 20 66 61 62 73 28 2a 73 |dPtr) &&| fabs(*s|
|000029b0| 64 50 74 72 2f 75 6e 63 | 6c 69 70 70 65 64 53 64 |dPtr/unc|lippedSd|
|000029c0| 53 61 76 65 2d 31 29 3e | 2e 30 31 29 29 7b 0d 09 |Save-1)>|.01)){..|
|000029d0| 09 09 09 2f 2f 20 74 61 | 6b 65 73 20 33 30 30 20 |...// ta|kes 300 |
|000029e0| 6d 73 0d 09 09 09 09 42 | 6f 75 6e 64 65 64 4e 6f |ms.....B|oundedNo|
|000029f0| 72 6d 61 6c 49 6e 74 65 | 67 65 72 73 28 2a 64 69 |rmalInte|gers(*di|
|00002a00| 73 74 72 69 62 75 74 69 | 6f 6e 48 61 6e 64 6c 65 |stributi|onHandle|
|00002a10| 2c 64 69 73 74 72 69 62 | 75 74 69 6f 6e 53 69 7a |,distrib|utionSiz|
|00002a20| 65 0d 09 09 09 09 09 2c | 2a 6d 65 61 6e 50 74 72 |e......,|*meanPtr|
|00002a30| 2c 2a 73 64 50 74 72 2c | 6c 6f 77 2c 68 69 67 68 |,*sdPtr,|low,high|
|00002a40| 29 3b 0d 09 09 09 7d 65 | 6c 73 65 7b 0d 09 09 09 |);....}e|lse{....|
|00002a50| 09 6a 3d 66 6c 6f 6f 72 | 28 30 2e 35 2b 2a 6d 65 |.j=floor|(0.5+*me|
|00002a60| 61 6e 50 74 72 2d 6d 65 | 61 6e 53 61 76 65 29 3b |anPtr-me|anSave);|
|00002a70| 0d 09 09 09 09 64 69 73 | 74 72 69 62 75 74 69 6f |.....dis|tributio|
|00002a80| 6e 3d 2a 64 69 73 74 72 | 69 62 75 74 69 6f 6e 48 |n=*distr|ibutionH|
|00002a90| 61 6e 64 6c 65 3b 0d 09 | 09 09 09 69 66 28 6a 21 |andle;..|...if(j!|
|00002aa0| 3d 30 29 66 6f 72 28 69 | 3d 30 3b 69 3c 64 69 73 |=0)for(i|=0;i<dis|
|00002ab0| 74 72 69 62 75 74 69 6f | 6e 53 69 7a 65 3b 69 2b |tributio|nSize;i+|
|00002ac0| 2b 29 64 69 73 74 72 69 | 62 75 74 69 6f 6e 5b 69 |+)distri|bution[i|
|00002ad0| 5d 2b 3d 6a 3b 0d 09 09 | 09 09 2a 6d 65 61 6e 50 |]+=j;...|..*meanP|
|00002ae0| 74 72 3d 6d 65 61 6e 53 | 61 76 65 2b 6a 3b 0d 09 |tr=meanS|ave+j;..|
|00002af0| 09 09 7d 0d 09 09 09 6c | 6f 77 53 61 76 65 3d 6c |..}....l|owSave=l|
|00002b00| 6f 77 3b 0d 09 09 09 68 | 69 67 68 53 61 76 65 3d |ow;....h|ighSave=|
|00002b10| 68 69 67 68 3b 0d 09 09 | 09 75 6e 63 6c 69 70 70 |high;...|.unclipp|
|00002b20| 65 64 53 64 53 61 76 65 | 3d 2a 73 64 50 74 72 3b |edSdSave|=*sdPtr;|
|00002b30| 0d 09 09 09 6d 65 61 6e | 53 61 76 65 3d 2a 6d 65 |....mean|Save=*me|
|00002b40| 61 6e 50 74 72 3b 0d 09 | 09 09 61 63 74 75 61 6c |anPtr;..|..actual|
|00002b50| 4d 65 61 6e 3d 4d 65 61 | 6e 57 28 2a 64 69 73 74 |Mean=Mea|nW(*dist|
|00002b60| 72 69 62 75 74 69 6f 6e | 48 61 6e 64 6c 65 2c 64 |ribution|Handle,d|
|00002b70| 69 73 74 72 69 62 75 74 | 69 6f 6e 53 69 7a 65 2c |istribut|ionSize,|
|00002b80| 26 61 63 74 75 61 6c 53 | 64 53 61 76 65 29 3b 0d |&actualS|dSave);.|
|00002b90| 09 09 7d 0d 09 09 61 63 | 74 75 61 6c 53 64 3d 61 |..}...ac|tualSd=a|
|00002ba0| 63 74 75 61 6c 53 64 53 | 61 76 65 3b 0d 09 09 61 |ctualSdS|ave;...a|
|00002bb0| 73 73 65 72 74 28 72 65 | 63 74 50 74 72 2d 3e 72 |ssert(re|ctPtr->r|
|00002bc0| 69 67 68 74 2d 72 65 63 | 74 50 74 72 2d 3e 6c 65 |ight-rec|tPtr->le|
|00002bd0| 66 74 3c 3d 73 69 7a 65 | 6f 66 28 70 69 78 29 2f |ft<=size|of(pix)/|
|00002be0| 73 69 7a 65 6f 66 28 2a | 70 69 78 29 29 3b 0d 09 |sizeof(*|pix));..|
|00002bf0| 09 2f 2f 48 4c 6f 63 6b | 28 28 48 61 6e 64 6c 65 |.//HLock|((Handle|
|00002c00| 29 64 69 73 74 72 69 62 | 75 74 69 6f 6e 48 61 6e |)distrib|utionHan|
|00002c10| 64 6c 65 29 3b 0d 09 09 | 64 69 73 74 72 69 62 75 |dle);...|distribu|
|00002c20| 74 69 6f 6e 3d 2a 64 69 | 73 74 72 69 62 75 74 69 |tion=*di|stributi|
|00002c30| 6f 6e 48 61 6e 64 6c 65 | 3b 0d 09 09 66 6f 72 28 |onHandle|;...for(|
|00002c40| 79 3d 72 65 63 74 50 74 | 72 2d 3e 74 6f 70 3b 79 |y=rectPt|r->top;y|
|00002c50| 3c 72 65 63 74 50 74 72 | 2d 3e 62 6f 74 74 6f 6d |<rectPtr|->bottom|
|00002c60| 3b 79 2b 2b 29 7b 0d 09 | 09 09 70 4c 3d 28 6c 6f |;y++){..|..pL=(lo|
|00002c70| 6e 67 20 2a 29 70 69 78 | 3b 0d 09 09 09 66 6f 72 |ng *)pix|;....for|
|00002c80| 28 78 3d 72 65 63 74 50 | 74 72 2d 3e 72 69 67 68 |(x=rectP|tr->righ|
|00002c90| 74 2d 72 65 63 74 50 74 | 72 2d 3e 6c 65 66 74 2d |t-rectPt|r->left-|
|00002ca0| 31 3b 78 3e 3d 30 3b 78 | 2d 2d 29 0d 09 09 09 09 |1;x>=0;x|--).....|
|00002cb0| 2a 70 4c 2b 2b 3d 64 69 | 73 74 72 69 62 75 74 69 |*pL++=di|stributi|
|00002cc0| 6f 6e 5b 6e 72 61 6e 64 | 28 64 69 73 74 72 69 62 |on[nrand|(distrib|
|00002cd0| 75 74 69 6f 6e 53 69 7a | 65 29 5d 3b 0d 09 09 09 |utionSiz|e)];....|
|00002ce0| 53 65 74 57 69 6e 64 6f | 77 50 69 78 65 6c 73 51 |SetWindo|wPixelsQ|
|00002cf0| 75 69 63 6b 6c 79 28 28 | 57 69 6e 64 6f 77 50 74 |uickly((|WindowPt|
|00002d00| 72 29 77 6f 72 6c 64 2c | 72 65 63 74 50 74 72 2d |r)world,|rectPtr-|
|00002d10| 3e 6c 65 66 74 2c 79 0d | 09 09 09 09 2c 70 69 78 |>left,y.|....,pix|
|00002d20| 2c 72 65 63 74 50 74 72 | 2d 3e 72 69 67 68 74 2d |,rectPtr|->right-|
|00002d30| 72 65 63 74 50 74 72 2d | 3e 6c 65 66 74 29 3b 0d |rectPtr-|>left);.|
|00002d40| 09 09 7d 0d 09 09 69 66 | 28 64 69 61 67 6e 6f 73 |..}...if|(diagnos|
|00002d50| 74 69 63 73 29 70 72 69 | 6e 74 66 28 22 75 6e 63 |tics)pri|ntf("unc|
|00002d60| 6c 69 70 70 65 64 53 64 | 20 25 66 2c 20 61 63 74 |lippedSd| %f, act|
|00002d70| 75 61 6c 53 64 20 25 66 | 2c 20 61 63 74 75 61 6c |ualSd %f|, actual|
|00002d80| 53 64 2f 75 6e 63 6c 69 | 70 70 65 64 53 64 20 25 |Sd/uncli|ppedSd %|
|00002d90| 66 5c 6e 22 0d 09 09 09 | 2c 2a 73 64 50 74 72 2c |f\n"....|,*sdPtr,|
|00002da0| 61 63 74 75 61 6c 53 64 | 2c 61 63 74 75 61 6c 53 |actualSd|,actualS|
|00002db0| 64 2f 28 2a 73 64 50 74 | 72 29 29 3b 0d 09 09 62 |d/(*sdPt|r));...b|
|00002dc0| 72 65 61 6b 3b 0d 09 63 | 61 73 65 20 6b 42 69 6e |reak;..c|ase kBin|
|00002dd0| 6f 6d 69 61 6c 50 64 66 | 3a 0d 09 09 2f 2f 20 55 |omialPdf|:...// U|
|00002de0| 73 65 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |se the n|umber of|
|00002df0| 20 68 65 61 64 73 20 69 | 6e 20 32 34 20 63 6f 69 | heads i|n 24 coi|
|00002e00| 6e 20 66 6c 69 70 73 20 | 61 73 20 61 20 72 61 6e |n flips |as a ran|
|00002e10| 64 6f 6d 20 76 61 72 69 | 61 62 6c 65 2e 0d 09 09 |dom vari|able....|
|00002e20| 2f 2f 20 49 74 20 63 61 | 6e 20 62 65 20 63 6f 6d |// It ca|n be com|
|00002e30| 70 75 74 65 64 20 71 75 | 69 63 6b 6c 79 20 61 6e |puted qu|ickly an|
|00002e40| 64 20 69 73 20 61 70 70 | 72 6f 78 69 6d 61 74 65 |d is app|roximate|
|00002e50| 6c 79 20 6e 6f 72 6d 61 | 6c 2e 0d 09 09 2f 2f 20 |ly norma|l....// |
|00002e60| 53 68 69 66 74 20 61 6e | 64 20 73 63 61 6c 65 20 |Shift an|d scale |
|00002e70| 74 6f 20 6f 62 74 61 69 | 6e 20 74 68 65 20 73 70 |to obtai|n the sp|
|00002e80| 65 63 69 66 69 65 64 20 | 6d 65 61 6e 20 61 6e 64 |ecified |mean and|
|00002e90| 20 76 61 72 69 61 6e 63 | 65 2e 0d 09 09 2f 2f 20 | varianc|e....// |
|00002ea0| 44 69 73 63 61 72 64 20 | 73 61 6d 70 6c 65 73 20 |Discard |samples |
|00002eb0| 6f 75 74 73 69 64 65 20 | 74 68 65 20 72 61 6e 67 |outside |the rang|
|00002ec0| 65 20 5b 6d 69 6e 2c 6d | 61 78 5d 2e 0d 09 09 2f |e [min,m|ax]..../|
|00002ed0| 2f 20 52 65 74 75 72 6e | 20 6d 65 61 6e 20 61 6e |/ Return| mean an|
|00002ee0| 64 20 73 64 20 6f 66 20 | 74 68 65 20 63 6c 69 70 |d sd of |the clip|
|00002ef0| 70 65 64 20 64 69 73 74 | 72 69 62 75 74 69 6f 6e |ped dist|ribution|
|00002f00| 2e 0d 09 09 62 69 6e 6f | 6d 69 61 6c 53 61 6d 70 |....bino|mialSamp|
|00002f10| 6c 65 73 3d 32 34 3b 09 | 2f 2f 20 73 68 6f 75 6c |les=24;.|// shoul|
|00002f20| 64 20 62 65 20 65 76 65 | 6e 20 28 66 6f 72 20 69 |d be eve|n (for i|
|00002f30| 6e 74 65 67 65 72 20 64 | 69 76 69 64 65 20 62 79 |nteger d|ivide by|
|00002f40| 20 32 29 0d 09 09 62 69 | 6e 6f 6d 69 61 6c 46 61 | 2)...bi|nomialFa|
|00002f50| 63 74 6f 72 3d 2a 73 64 | 50 74 72 2f 73 71 72 74 |ctor=*sd|Ptr/sqrt|
|00002f60| 28 62 69 6e 6f 6d 69 61 | 6c 53 61 6d 70 6c 65 73 |(binomia|lSamples|
|00002f70| 2a 30 2e 32 35 29 3b 0d | 09 09 2f 2a 0d 09 09 54 |*0.25);.|../*...T|
|00002f80| 68 65 20 65 6d 70 69 72 | 69 63 61 6c 20 61 70 70 |he empir|ical app|
|00002f90| 72 6f 61 63 68 20 6f 66 | 20 61 63 74 75 61 6c 6c |roach of| actuall|
|00002fa0| 79 20 6d 65 61 73 75 72 | 69 6e 67 20 74 68 65 20 |y measur|ing the |
|00002fb0| 6d 65 61 6e 20 61 6e 64 | 20 76 61 72 69 61 6e 63 |mean and| varianc|
|00002fc0| 65 0d 09 09 6f 66 20 6f | 75 72 20 6e 6f 69 73 65 |e...of o|ur noise|
|00002fd0| 20 67 65 6e 65 72 61 74 | 6f 72 20 64 65 6d 61 6e | generat|or deman|
|00002fe0| 64 73 20 74 68 61 74 20 | 77 65 20 70 72 6f 64 75 |ds that |we produ|
|00002ff0| 63 65 20 61 0d 09 09 72 | 65 61 73 6f 6e 61 62 6c |ce a...r|easonabl|
|00003000| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 73 61 6d 70 |e number| of samp|
|00003010| 6c 65 73 2c 20 61 74 20 | 6c 65 61 73 74 20 31 30 |les, at |least 10|
|00003020| 30 30 2e 20 41 6e 79 20 | 65 78 74 72 61 20 73 61 |00. Any |extra sa|
|00003030| 6d 70 6c 65 73 20 61 72 | 65 20 6c 61 74 65 72 0d |mples ar|e later.|
|00003040| 09 09 64 69 73 63 61 72 | 64 65 64 2e 0d 09 09 2a |..discar|ded....*|
|00003050| 2f 0d 09 09 61 73 73 65 | 72 74 28 72 65 63 74 50 |/...asse|rt(rectP|
|00003060| 74 72 2d 3e 72 69 67 68 | 74 2d 72 65 63 74 50 74 |tr->righ|t-rectPt|
|00003070| 72 2d 3e 6c 65 66 74 3c | 3d 73 69 7a 65 6f 66 28 |r->left<|=sizeof(|
|00003080| 70 69 78 29 2f 73 69 7a | 65 6f 66 28 2a 70 69 78 |pix)/siz|eof(*pix|
|00003090| 29 29 3b 0d 09 09 65 78 | 74 72 61 53 61 6d 70 6c |));...ex|traSampl|
|000030a0| 65 73 3d 63 65 69 6c 28 | 31 30 30 30 2e 30 2f 28 |es=ceil(|1000.0/(|
|000030b0| 72 65 63 74 50 74 72 2d | 3e 62 6f 74 74 6f 6d 2d |rectPtr-|>bottom-|
|000030c0| 72 65 63 74 50 74 72 2d | 3e 74 6f 70 29 29 0d 09 |rectPtr-|>top))..|
|000030d0| 09 09 2d 28 72 65 63 74 | 50 74 72 2d 3e 72 69 67 |..-(rect|Ptr->rig|
|000030e0| 68 74 2d 72 65 63 74 50 | 74 72 2d 3e 6c 65 66 74 |ht-rectP|tr->left|
|000030f0| 29 3b 0d 09 09 69 66 28 | 65 78 74 72 61 53 61 6d |);...if(|extraSam|
|00003100| 70 6c 65 73 3c 30 29 65 | 78 74 72 61 53 61 6d 70 |ples<0)e|xtraSamp|
|00003110| 6c 65 73 3d 30 3b 0d 09 | 09 61 3d 61 61 3d 30 2e |les=0;..|.a=aa=0.|
|00003120| 30 3b 0d 09 09 6e 3d 30 | 3b 0d 09 09 66 6f 72 28 |0;...n=0|;...for(|
|00003130| 79 3d 72 65 63 74 50 74 | 72 2d 3e 74 6f 70 3b 20 |y=rectPt|r->top; |
|00003140| 79 3c 72 65 63 74 50 74 | 72 2d 3e 62 6f 74 74 6f |y<rectPt|r->botto|
|00003150| 6d 3b 20 79 2b 2b 29 7b | 0d 09 09 09 70 4c 3d 28 |m; y++){|....pL=(|
|00003160| 6c 6f 6e 67 20 2a 29 70 | 69 78 3b 0d 09 09 09 66 |long *)p|ix;....f|
|00003170| 6f 72 28 78 3d 72 65 63 | 74 50 74 72 2d 3e 72 69 |or(x=rec|tPtr->ri|
|00003180| 67 68 74 2d 72 65 63 74 | 50 74 72 2d 3e 6c 65 66 |ght-rect|Ptr->lef|
|00003190| 74 2d 31 3b 20 78 3e 3d | 2d 65 78 74 72 61 53 61 |t-1; x>=|-extraSa|
|000031a0| 6d 70 6c 65 73 3b 20 78 | 2d 2d 29 7b 0d 09 09 09 |mples; x|--){....|
|000031b0| 09 64 6f 7b 0d 09 09 09 | 09 09 73 61 6d 70 6c 65 |.do{....|..sample|
|000031c0| 3d 66 6c 6f 6f 72 28 30 | 2e 35 2b 2a 6d 65 61 6e |=floor(0|.5+*mean|
|000031d0| 50 74 72 2b 62 69 6e 6f | 6d 69 61 6c 46 61 63 74 |Ptr+bino|mialFact|
|000031e0| 6f 72 0d 09 09 09 09 09 | 09 2a 28 42 69 6e 6f 6d |or......|.*(Binom|
|000031f0| 69 61 6c 53 61 6d 70 6c | 65 51 75 69 63 6b 6c 79 |ialSampl|eQuickly|
|00003200| 28 62 69 6e 6f 6d 69 61 | 6c 53 61 6d 70 6c 65 73 |(binomia|lSamples|
|00003210| 29 2d 62 69 6e 6f 6d 69 | 61 6c 53 61 6d 70 6c 65 |)-binomi|alSample|
|00003220| 73 2f 32 29 29 3b 0d 09 | 09 09 09 7d 77 68 69 6c |s/2));..|...}whil|
|00003230| 65 28 73 61 6d 70 6c 65 | 3c 6c 6f 77 20 7c 7c 20 |e(sample|<low || |
|00003240| 73 61 6d 70 6c 65 3e 68 | 69 67 68 29 3b 0d 09 09 |sample>h|igh);...|
|00003250| 09 09 61 2b 3d 73 61 6d | 70 6c 65 3b 0d 09 09 09 |..a+=sam|ple;....|
|00003260| 09 61 61 2b 3d 28 6c 6f | 6e 67 29 73 61 6d 70 6c |.aa+=(lo|ng)sampl|
|00003270| 65 2a 28 6c 6f 6e 67 29 | 73 61 6d 70 6c 65 3b 0d |e*(long)|sample;.|
|00003280| 09 09 09 09 6e 2b 2b 3b | 0d 09 09 09 09 69 66 28 |....n++;|.....if(|
|00003290| 78 3e 3d 30 29 2a 70 4c | 2b 2b 3d 73 61 6d 70 6c |x>=0)*pL|++=sampl|
|000032a0| 65 3b 0d 09 09 09 7d 0d | 09 09 09 53 65 74 57 69 |e;....}.|...SetWi|
|000032b0| 6e 64 6f 77 50 69 78 65 | 6c 73 51 75 69 63 6b 6c |ndowPixe|lsQuickl|
|000032c0| 79 28 28 57 69 6e 64 6f | 77 50 74 72 29 77 6f 72 |y((Windo|wPtr)wor|
|000032d0| 6c 64 2c 72 65 63 74 50 | 74 72 2d 3e 6c 65 66 74 |ld,rectP|tr->left|
|000032e0| 2c 79 0d 09 09 09 09 2c | 70 69 78 2c 72 65 63 74 |,y.....,|pix,rect|
|000032f0| 50 74 72 2d 3e 72 69 67 | 68 74 2d 72 65 63 74 50 |Ptr->rig|ht-rectP|
|00003300| 74 72 2d 3e 6c 65 66 74 | 29 3b 0d 09 09 7d 0d 09 |tr->left|);...}..|
|00003310| 09 61 63 74 75 61 6c 4d | 65 61 6e 3d 61 2f 6e 3b |.actualM|ean=a/n;|
|00003320| 0d 09 09 61 63 74 75 61 | 6c 53 64 3d 73 71 72 74 |...actua|lSd=sqrt|
|00003330| 28 61 61 2f 6e 2d 61 63 | 74 75 61 6c 4d 65 61 6e |(aa/n-ac|tualMean|
|00003340| 2a 61 63 74 75 61 6c 4d | 65 61 6e 29 3b 0d 09 09 |*actualM|ean);...|
|00003350| 69 66 28 64 69 61 67 6e | 6f 73 74 69 63 73 29 70 |if(diagn|ostics)p|
|00003360| 72 69 6e 74 66 28 22 75 | 6e 63 6c 69 70 70 65 64 |rintf("u|nclipped|
|00003370| 53 64 20 25 66 2c 20 61 | 63 74 75 61 6c 53 64 20 |Sd %f, a|ctualSd |
|00003380| 25 66 2c 20 61 63 74 75 | 61 6c 53 64 2f 75 6e 63 |%f, actu|alSd/unc|
|00003390| 6c 69 70 70 65 64 53 64 | 20 25 66 2c 20 6e 20 25 |lippedSd| %f, n %|
|000033a0| 6c 64 5c 6e 22 0d 09 09 | 09 2c 2a 73 64 50 74 72 |ld\n"...|.,*sdPtr|
|000033b0| 2c 61 63 74 75 61 6c 53 | 64 2c 61 63 74 75 61 6c |,actualS|d,actual|
|000033c0| 53 64 2f 28 2a 73 64 50 | 74 72 29 2c 6e 29 3b 0d |Sd/(*sdP|tr),n);.|
|000033d0| 09 09 62 72 65 61 6b 3b | 0d 09 64 65 66 61 75 6c |..break;|..defaul|
|000033e0| 74 3a 0d 09 09 50 72 69 | 6e 74 66 45 78 69 74 28 |t:...Pri|ntfExit(|
|000033f0| 22 25 73 2c 25 64 3a 20 | 4e 6f 20 73 75 63 68 20 |"%s,%d: |No such |
|00003400| 70 64 66 20 25 64 5c 6e | 22 2c 5f 5f 46 49 4c 45 |pdf %d\n|",__FILE|
|00003410| 5f 5f 2c 5f 5f 4c 49 4e | 45 5f 5f 2c 28 69 6e 74 |__,__LIN|E__,(int|
|00003420| 29 70 64 66 4b 69 6e 64 | 29 3b 0d 09 7d 0d 09 69 |)pdfKind|);..}..i|
|00003430| 66 28 64 69 61 67 6e 6f | 73 74 69 63 73 29 7b 0d |f(diagno|stics){.|
|00003440| 09 09 49 6d 61 67 65 53 | 74 61 74 69 73 74 69 63 |..ImageS|tatistic|
|00003450| 73 28 77 6f 72 6c 64 2c | 72 65 63 74 50 74 72 2c |s(world,|rectPtr,|
|00003460| 26 61 63 74 75 61 6c 4d | 69 6e 2c 26 61 63 74 75 |&actualM|in,&actu|
|00003470| 61 6c 4d 61 78 2c 26 61 | 63 74 75 61 6c 4d 65 61 |alMax,&a|ctualMea|
|00003480| 6e 2c 26 6d 65 61 6e 53 | 71 75 61 72 65 29 3b 0d |n,&meanS|quare);.|
|00003490| 09 09 69 66 28 61 63 74 | 75 61 6c 4d 61 78 3e 6d |..if(act|ualMax>m|
|000034a0| 61 78 20 7c 7c 20 61 63 | 74 75 61 6c 4d 69 6e 3c |ax || ac|tualMin<|
|000034b0| 6d 69 6e 29 70 72 69 6e | 74 66 28 22 5c 6e 49 4d |min)prin|tf("\nIM|
|000034c0| 41 47 45 20 4f 56 45 52 | 46 4c 4f 57 20 45 52 52 |AGE OVER|FLOW ERR|
|000034d0| 4f 52 3a 5c 6e 22 29 3b | 0d 09 09 70 72 69 6e 74 |OR:\n");|...print|
|000034e0| 66 28 22 6e 6f 69 73 65 | 20 61 63 74 75 61 6c 4d |f("noise| actualM|
|000034f0| 69 6e 20 25 6c 64 b3 25 | 64 2c 20 61 63 74 75 61 |in %ld.%|d, actua|
|00003500| 6c 4d 61 78 20 25 6c 64 | b2 25 64 2c 20 61 63 74 |lMax %ld|.%d, act|
|00003510| 75 61 6c 4d 65 61 6e 20 | 25 2e 31 66 c5 25 2e 31 |ualMean |%.1f.%.1|
|00003520| 66 2c 20 72 6d 73 20 25 | 2e 31 66 c5 25 2e 31 66 |f, rms %|.1f.%.1f|
|00003530| c5 25 2e 31 66 5c 6e 22 | 0d 09 09 09 2c 61 63 74 |.%.1f\n"|....,act|
|00003540| 75 61 6c 4d 69 6e 2c 28 | 69 6e 74 29 6d 69 6e 0d |ualMin,(|int)min.|
|00003550| 09 09 09 2c 61 63 74 75 | 61 6c 4d 61 78 2c 28 69 |...,actu|alMax,(i|
|00003560| 6e 74 29 6d 61 78 0d 09 | 09 09 2c 61 63 74 75 61 |nt)max..|..,actua|
|00003570| 6c 4d 65 61 6e 2c 2a 6d | 65 61 6e 50 74 72 0d 09 |lMean,*m|eanPtr..|
|00003580| 09 09 2c 73 71 72 74 28 | 6d 65 61 6e 53 71 75 61 |..,sqrt(|meanSqua|
|00003590| 72 65 29 2c 61 63 74 75 | 61 6c 53 64 2c 2a 73 64 |re),actu|alSd,*sd|
|000035a0| 50 74 72 29 3b 0d 09 09 | 61 73 73 65 72 74 28 61 |Ptr);...|assert(a|
|000035b0| 63 74 75 61 6c 4d 61 78 | 3c 3d 6d 61 78 20 26 26 |ctualMax|<=max &&|
|000035c0| 20 61 63 74 75 61 6c 4d | 69 6e 3e 3d 6d 69 6e 29 | actualM|in>=min)|
|000035d0| 3b 0d 09 7d 0d 64 6f 6e | 65 3a 0d 09 2a 73 64 50 |;..}.don|e:..*sdP|
|000035e0| 74 72 3d 61 63 74 75 61 | 6c 53 64 3b 0d 09 2a 6d |tr=actua|lSd;..*m|
|000035f0| 65 61 6e 50 74 72 3d 61 | 63 74 75 61 6c 4d 65 61 |eanPtr=a|ctualMea|
|00003600| 6e 3b 0d 09 72 65 74 75 | 72 6e 20 65 72 72 6f 72 |n;..retu|rn error|
|00003610| 3b 0d 7d 0d 0d 4f 53 45 | 72 72 20 4e 6f 69 73 65 |;.}..OSE|rr Noise|
|00003620| 50 64 66 41 64 64 28 47 | 57 6f 72 6c 64 50 74 72 |PdfAdd(G|WorldPtr|
|00003630| 20 77 6f 72 6c 64 2c 52 | 65 63 74 20 2a 72 65 63 | world,R|ect *rec|
|00003640| 74 50 74 72 0d 09 2c 69 | 6e 74 20 70 64 66 4b 69 |tPtr..,i|nt pdfKi|
|00003650| 6e 64 2c 64 6f 75 62 6c | 65 20 2a 6d 65 61 6e 50 |nd,doubl|e *meanP|
|00003660| 74 72 2c 64 6f 75 62 6c | 65 20 2a 73 64 50 74 72 |tr,doubl|e *sdPtr|
|00003670| 2c 69 6e 74 20 6d 69 6e | 2c 69 6e 74 20 6d 61 78 |,int min|,int max|
|00003680| 29 0d 7b 0d 09 47 57 6f | 72 6c 64 50 74 72 20 6e |).{..GWo|rldPtr n|
|00003690| 6f 69 73 65 57 6f 72 6c | 64 3b 0d 09 47 44 48 61 |oiseWorl|d;..GDHa|
|000036a0| 6e 64 6c 65 20 64 65 76 | 69 63 65 3b 0d 09 69 6e |ndle dev|ice;..in|
|000036b0| 74 20 65 72 72 6f 72 3d | 30 2c 70 69 78 65 6c 53 |t error=|0,pixelS|
|000036c0| 69 7a 65 2c 69 64 3b 0d | 20 20 20 20 64 6f 75 62 |ize,id;.| doub|
|000036d0| 6c 65 20 6d 65 61 6e 53 | 71 75 61 72 65 2c 61 63 |le meanS|quare,ac|
|000036e0| 74 75 61 6c 4d 65 61 6e | 3b 0d 09 6c 6f 6e 67 20 |tualMean|;..long |
|000036f0| 61 63 74 75 61 6c 4d 69 | 6e 2c 61 63 74 75 61 6c |actualMi|n,actual|
|00003700| 4d 61 78 3b 0d 09 43 6f | 6c 6f 72 54 61 62 6c 65 |Max;..Co|lorTable|
|00003710| 20 2a 2a 63 74 3b 0d 09 | 6c 6f 6e 67 20 63 6f 70 | **ct;..|long cop|
|00003720| 79 4d 6f 64 65 3b 0d 0d | 09 61 73 73 65 72 74 28 |yMode;..|.assert(|
|00003730| 77 6f 72 6c 64 21 3d 4e | 55 4c 4c 29 3b 0d 09 64 |world!=N|ULL);..d|
|00003740| 65 76 69 63 65 3d 47 65 | 74 57 69 6e 64 6f 77 44 |evice=Ge|tWindowD|
|00003750| 65 76 69 63 65 28 28 57 | 69 6e 64 6f 77 50 74 72 |evice((W|indowPtr|
|00003760| 29 77 6f 72 6c 64 29 3b | 0d 09 69 64 3d 70 69 78 |)world);|..id=pix|
|00003770| 65 6c 53 69 7a 65 3d 28 | 2a 2a 28 2a 2a 64 65 76 |elSize=(|**(**dev|
|00003780| 69 63 65 29 2e 67 64 50 | 4d 61 70 29 2e 70 69 78 |ice).gdP|Map).pix|
|00003790| 65 6c 53 69 7a 65 3b 0d | 09 69 66 28 69 64 3e 32 |elSize;.|.if(id>2|
|000037a0| 29 69 64 2b 3d 33 32 3b | 0d 09 63 74 3d 47 65 74 |)id+=32;|..ct=Get|
|000037b0| 43 54 61 62 6c 65 28 69 | 64 29 3b 09 2f 2f 20 67 |CTable(i|d);.// g|
|000037c0| 72 61 79 20 72 61 6d 70 | 0d 09 61 73 73 65 72 74 |ray ramp|..assert|
|000037d0| 28 63 74 21 3d 4e 55 4c | 4c 29 3b 0d 09 65 72 72 |(ct!=NUL|L);..err|
|000037e0| 6f 72 3d 4e 65 77 47 57 | 6f 72 6c 64 28 26 6e 6f |or=NewGW|orld(&no|
|000037f0| 69 73 65 57 6f 72 6c 64 | 2c 70 69 78 65 6c 53 69 |iseWorld|,pixelSi|
|00003800| 7a 65 2c 72 65 63 74 50 | 74 72 2c 63 74 2c 30 2c |ze,rectP|tr,ct,0,|
|00003810| 30 29 3b 0d 09 69 66 28 | 65 72 72 6f 72 29 65 72 |0);..if(|error)er|
|00003820| 72 6f 72 3d 4e 65 77 47 | 57 6f 72 6c 64 28 26 6e |ror=NewG|World(&n|
|00003830| 6f 69 73 65 57 6f 72 6c | 64 2c 70 69 78 65 6c 53 |oiseWorl|d,pixelS|
|00003840| 69 7a 65 2c 72 65 63 74 | 50 74 72 2c 63 74 2c 30 |ize,rect|Ptr,ct,0|
|00003850| 2c 75 73 65 54 65 6d 70 | 4d 65 6d 29 3b 0d 09 69 |,useTemp|Mem);..i|
|00003860| 66 28 65 72 72 6f 72 29 | 72 65 74 75 72 6e 20 65 |f(error)|return e|
|00003870| 72 72 6f 72 3b 0d 09 65 | 72 72 6f 72 3d 4e 6f 69 |rror;..e|rror=Noi|
|00003880| 73 65 50 64 66 46 69 6c | 6c 28 6e 6f 69 73 65 57 |sePdfFil|l(noiseW|
|00003890| 6f 72 6c 64 2c 72 65 63 | 74 50 74 72 2c 70 64 66 |orld,rec|tPtr,pdf|
|000038a0| 4b 69 6e 64 2c 6d 65 61 | 6e 50 74 72 2c 73 64 50 |Kind,mea|nPtr,sdP|
|000038b0| 74 72 2c 6d 69 6e 2c 6d | 61 78 29 3b 0d 09 69 66 |tr,min,m|ax);..if|
|000038c0| 28 65 72 72 6f 72 29 67 | 6f 74 6f 20 64 6f 6e 65 |(error)g|oto done|
|000038d0| 3b 0d 09 69 66 28 6d 69 | 6e 3e 3d 30 29 63 6f 70 |;..if(mi|n>=0)cop|
|000038e0| 79 4d 6f 64 65 3d 61 64 | 64 4f 76 65 72 50 61 72 |yMode=ad|dOverPar|
|000038f0| 61 6c 6c 65 6c 4c 69 74 | 65 72 61 6c 6c 79 3b 09 |allelLit|erally;.|
|00003900| 2f 2f 20 6e 6f 20 6f 76 | 65 72 66 6c 6f 77 0d 09 |// no ov|erflow..|
|00003910| 65 6c 73 65 20 63 6f 70 | 79 4d 6f 64 65 3d 61 64 |else cop|yMode=ad|
|00003920| 64 4f 76 65 72 3b 09 09 | 09 09 09 09 09 2f 2f 20 |dOver;..|.....// |
|00003930| 22 73 69 67 6e 22 20 62 | 69 74 20 6d 61 79 20 6f |"sign" b|it may o|
|00003940| 76 65 72 66 6c 6f 77 0d | 09 65 72 72 6f 72 3d 43 |verflow.|.error=C|
|00003950| 6f 70 79 57 69 6e 64 6f | 77 73 28 6e 6f 69 73 65 |opyWindo|ws(noise|
|00003960| 57 6f 72 6c 64 2c 77 6f | 72 6c 64 2c 72 65 63 74 |World,wo|rld,rect|
|00003970| 50 74 72 2c 72 65 63 74 | 50 74 72 2c 63 6f 70 79 |Ptr,rect|Ptr,copy|
|00003980| 4d 6f 64 65 2c 4e 55 4c | 4c 29 3b 0d 09 69 66 28 |Mode,NUL|L);..if(|
|00003990| 65 72 72 6f 72 29 50 72 | 69 6e 74 66 45 78 69 74 |error)Pr|intfExit|
|000039a0| 28 22 25 73 20 6c 69 6e | 65 20 25 64 3a 20 43 6f |("%s lin|e %d: Co|
|000039b0| 70 79 57 69 6e 64 6f 77 | 73 20 65 72 72 6f 72 20 |pyWindow|s error |
|000039c0| 25 64 5c 6e 22 2c 5f 5f | 46 49 4c 45 5f 5f 2c 5f |%d\n",__|FILE__,_|
|000039d0| 5f 4c 49 4e 45 5f 5f 2c | 65 72 72 6f 72 29 3b 0d |_LINE__,|error);.|
|000039e0| 09 69 66 28 64 69 61 67 | 6e 6f 73 74 69 63 73 29 |.if(diag|nostics)|
|000039f0| 7b 0d 09 09 49 6d 61 67 | 65 53 74 61 74 69 73 74 |{...Imag|eStatist|
|00003a00| 69 63 73 28 77 6f 72 6c | 64 2c 26 77 6f 72 6c 64 |ics(worl|d,&world|
|00003a10| 2d 3e 70 6f 72 74 52 65 | 63 74 2c 26 61 63 74 75 |->portRe|ct,&actu|
|00003a20| 61 6c 4d 69 6e 2c 26 61 | 63 74 75 61 6c 4d 61 78 |alMin,&a|ctualMax|
|00003a30| 2c 26 61 63 74 75 61 6c | 4d 65 61 6e 2c 26 6d 65 |,&actual|Mean,&me|
|00003a40| 61 6e 53 71 75 61 72 65 | 29 3b 0d 09 09 69 66 28 |anSquare|);...if(|
|00003a50| 61 63 74 75 61 6c 4d 61 | 78 3e 6d 61 78 20 7c 7c |actualMa|x>max |||
|00003a60| 20 61 63 74 75 61 6c 4d | 69 6e 3c 6d 69 6e 20 7c | actualM|in<min ||
|00003a70| 7c 20 64 69 61 67 6e 6f | 73 74 69 63 73 29 7b 0d || diagno|stics){.|
|00003a80| 09 09 09 70 72 69 6e 74 | 66 28 22 73 69 67 6e 61 |...print|f("signa|
|00003a90| 6c 2b 6e 6f 69 73 65 20 | 61 63 74 75 61 6c 4d 69 |l+noise |actualMi|
|00003aa0| 6e 20 25 6c 64 2c 20 61 | 63 74 75 61 6c 4d 61 78 |n %ld, a|ctualMax|
|00003ab0| 20 25 6c 64 2c 20 61 63 | 74 75 61 6c 4d 65 61 6e | %ld, ac|tualMean|
|00003ac0| 20 25 2e 31 66 2c 20 61 | 63 74 75 61 6c 53 64 20 | %.1f, a|ctualSd |
|00003ad0| 25 2e 31 66 5c 6e 22 0d | 09 09 09 09 2c 61 63 74 |%.1f\n".|....,act|
|00003ae0| 75 61 6c 4d 69 6e 2c 61 | 63 74 75 61 6c 4d 61 78 |ualMin,a|ctualMax|
|00003af0| 2c 61 63 74 75 61 6c 4d | 65 61 6e 2c 73 71 72 74 |,actualM|ean,sqrt|
|00003b00| 28 6d 65 61 6e 53 71 75 | 61 72 65 2d 61 63 74 75 |(meanSqu|are-actu|
|00003b10| 61 6c 4d 65 61 6e 2a 61 | 63 74 75 61 6c 4d 65 61 |alMean*a|ctualMea|
|00003b20| 6e 29 29 3b 0d 09 09 7d | 0d 09 7d 0d 64 6f 6e 65 |n));...}|..}.done|
|00003b30| 3a 0d 09 44 69 73 70 6f | 73 65 47 57 6f 72 6c 64 |:..Dispo|seGWorld|
|00003b40| 28 6e 6f 69 73 65 57 6f | 72 6c 64 29 3b 0d 09 72 |(noiseWo|rld);..r|
|00003b50| 65 74 75 72 6e 20 65 72 | 72 6f 72 3b 0d 7d 0d 0d |eturn er|ror;.}..|
|00003b60| 76 6f 69 64 20 47 65 74 | 47 6f 6f 64 4e 6f 69 73 |void Get|GoodNois|
|00003b70| 65 50 64 66 42 6f 75 6e | 64 73 28 69 6e 74 20 70 |ePdfBoun|ds(int p|
|00003b80| 64 66 4b 69 6e 64 2c 64 | 6f 75 62 6c 65 20 6d 65 |dfKind,d|ouble me|
|00003b90| 61 6e 2c 64 6f 75 62 6c | 65 20 63 6c 69 70 70 65 |an,doubl|e clippe|
|00003ba0| 64 53 64 0d 09 2c 64 6f | 75 62 6c 65 20 2a 75 6e |dSd..,do|uble *un|
|00003bb0| 63 6c 69 70 70 65 64 53 | 64 50 74 72 2c 69 6e 74 |clippedS|dPtr,int|
|00003bc0| 20 2a 6d 69 6e 50 74 72 | 2c 69 6e 74 20 2a 6d 61 | *minPtr|,int *ma|
|00003bd0| 78 50 74 72 29 0d 7b 0d | 09 64 6f 75 62 6c 65 20 |xPtr).{.|.double |
|00003be0| 64 4d 61 78 2c 64 4d 69 | 6e 2c 63 6c 69 70 70 65 |dMax,dMi|n,clippe|
|00003bf0| 64 53 64 31 3b 0d 09 69 | 6e 74 20 6c 6f 77 2c 68 |dSd1;..i|nt low,h|
|00003c00| 69 67 68 3b 0d 09 0d 09 | 61 73 73 65 72 74 28 75 |igh;....|assert(u|
|00003c10| 6e 63 6c 69 70 70 65 64 | 53 64 50 74 72 21 3d 4e |nclipped|SdPtr!=N|
|00003c20| 55 4c 4c 20 26 26 20 6d | 69 6e 50 74 72 21 3d 4e |ULL && m|inPtr!=N|
|00003c30| 55 4c 4c 20 26 26 20 6d | 61 78 50 74 72 21 3d 4e |ULL && m|axPtr!=N|
|00003c40| 55 4c 4c 29 3b 0d 09 61 | 73 73 65 72 74 28 63 6c |ULL);..a|ssert(cl|
|00003c50| 69 70 70 65 64 53 64 3e | 3d 30 29 3b 0d 09 61 73 |ippedSd>|=0);..as|
|00003c60| 73 65 72 74 28 2a 6d 61 | 78 50 74 72 3e 3d 2a 6d |sert(*ma|xPtr>=*m|
|00003c70| 69 6e 50 74 72 29 3b 0d | 09 0d 09 2f 2f 20 64 4d |inPtr);.|...// dM|
|00003c80| 61 78 2c 64 4d 69 6e 2c | 63 6c 69 70 70 65 64 53 |ax,dMin,|clippedS|
|00003c90| 64 31 0d 09 73 77 69 74 | 63 68 28 70 64 66 4b 69 |d1..swit|ch(pdfKi|
|00003ca0| 6e 64 29 7b 0d 09 63 61 | 73 65 20 6b 42 69 6e 61 |nd){..ca|se kBina|
|00003cb0| 72 79 50 64 66 3a 0d 09 | 09 64 4d 61 78 3d 63 6c |ryPdf:..|.dMax=cl|
|00003cc0| 69 70 70 65 64 53 64 3b | 0d 09 09 64 4d 69 6e 3d |ippedSd;|...dMin=|
|00003cd0| 2d 64 4d 61 78 3b 0d 09 | 09 63 6c 69 70 70 65 64 |-dMax;..|.clipped|
|00003ce0| 53 64 31 3d 31 3b 0d 09 | 09 62 72 65 61 6b 3b 0d |Sd1=1;..|.break;.|
|00003cf0| 09 63 61 73 65 20 6b 55 | 6e 69 66 6f 72 6d 50 64 |.case kU|niformPd|
|00003d00| 66 3a 0d 09 09 64 4d 61 | 78 3d 73 71 72 74 28 33 |f:...dMa|x=sqrt(3|
|00003d10| 29 2a 63 6c 69 70 70 65 | 64 53 64 2d 30 2e 35 3b |)*clippe|dSd-0.5;|
|00003d20| 0d 09 09 64 4d 69 6e 3d | 2d 64 4d 61 78 3b 0d 09 |...dMin=|-dMax;..|
|00003d30| 09 63 6c 69 70 70 65 64 | 53 64 31 3d 31 3b 0d 09 |.clipped|Sd1=1;..|
|00003d40| 09 62 72 65 61 6b 3b 0d | 09 63 61 73 65 20 6b 42 |.break;.|.case kB|
|00003d50| 69 6e 6f 6d 69 61 6c 50 | 64 66 3a 0d 09 09 64 4d |inomialP|df:...dM|
|00003d60| 61 78 3d 32 2a 63 6c 69 | 70 70 65 64 53 64 3b 0d |ax=2*cli|ppedSd;.|
|00003d70| 09 09 64 4d 69 6e 3d 2d | 64 4d 61 78 3b 0d 09 09 |..dMin=-|dMax;...|
|00003d80| 63 6c 69 70 70 65 64 53 | 64 31 3d 30 2e 38 35 3b |clippedS|d1=0.85;|
|00003d90| 0d 09 09 62 72 65 61 6b | 3b 0d 09 63 61 73 65 20 |...break|;..case |
|00003da0| 6b 47 61 75 73 73 69 61 | 6e 50 64 66 3a 0d 09 09 |kGaussia|nPdf:...|
|00003db0| 64 4d 61 78 3d 32 2a 63 | 6c 69 70 70 65 64 53 64 |dMax=2*c|lippedSd|
|00003dc0| 3b 0d 09 09 64 4d 69 6e | 3d 2d 64 4d 61 78 3b 0d |;...dMin|=-dMax;.|
|00003dd0| 09 09 63 6c 69 70 70 65 | 64 53 64 31 3d 30 2e 37 |..clippe|dSd1=0.7|
|00003de0| 33 37 3b 0d 09 09 62 72 | 65 61 6b 3b 0d 09 7d 0d |37;...br|eak;..}.|
|00003df0| 09 2f 2f 20 68 69 67 68 | 20 61 6e 64 20 6c 6f 77 |.// high| and low|
|00003e00| 20 61 72 65 20 74 68 65 | 20 65 78 74 72 65 6d 65 | are the| extreme|
|00003e10| 73 20 6f 66 20 74 68 65 | 20 70 64 66 2e 0d 09 2f |s of the| pdf.../|
|00003e20| 2f 20 54 68 65 20 68 69 | 67 68 2d 6c 6f 77 20 64 |/ The hi|gh-low d|
|00003e30| 69 66 66 65 72 65 6e 63 | 65 20 69 73 20 6d 6f 72 |ifferenc|e is mor|
|00003e40| 65 20 69 6d 70 6f 72 74 | 61 6e 74 20 74 68 61 6e |e import|ant than|
|00003e50| 20 74 68 65 20 61 62 73 | 6f 6c 75 74 65 20 76 61 | the abs|olute va|
|00003e60| 6c 75 65 20 6f 66 20 65 | 69 74 68 65 72 2e 0d 09 |lue of e|ither...|
|00003e70| 61 73 73 65 72 74 28 64 | 4d 61 78 3e 3d 64 4d 69 |assert(d|Max>=dMi|
|00003e80| 6e 29 3b 0d 09 6c 6f 77 | 3d 4d 41 58 28 66 6c 6f |n);..low|=MAX(flo|
|00003e90| 6f 72 28 30 2e 35 2b 6d | 65 61 6e 2b 64 4d 69 6e |or(0.5+m|ean+dMin|
|00003ea0| 29 2c 2a 6d 69 6e 50 74 | 72 29 3b 0d 09 68 69 67 |),*minPt|r);..hig|
|00003eb0| 68 3d 4d 49 4e 28 66 6c | 6f 6f 72 28 30 2e 35 2b |h=MIN(fl|oor(0.5+|
|00003ec0| 6c 6f 77 2b 28 64 4d 61 | 78 2d 64 4d 69 6e 29 29 |low+(dMa|x-dMin))|
|00003ed0| 2c 2a 6d 61 78 50 74 72 | 29 3b 0d 09 6c 6f 77 3d |,*maxPtr|);..low=|
|00003ee0| 4d 41 58 28 66 6c 6f 6f | 72 28 30 2e 35 2b 68 69 |MAX(floo|r(0.5+hi|
|00003ef0| 67 68 2d 28 64 4d 61 78 | 2d 64 4d 69 6e 29 29 2c |gh-(dMax|-dMin)),|
|00003f00| 2a 6d 69 6e 50 74 72 29 | 3b 0d 09 69 66 28 6c 6f |*minPtr)|;..if(lo|
|00003f10| 77 3d 3d 68 69 67 68 20 | 26 26 20 63 6c 69 70 70 |w==high |&& clipp|
|00003f20| 65 64 53 64 3e 30 29 7b | 0d 09 09 69 66 28 68 69 |edSd>0){|...if(hi|
|00003f30| 67 68 3c 2a 6d 61 78 50 | 74 72 29 68 69 67 68 2b |gh<*maxP|tr)high+|
|00003f40| 2b 3b 0d 09 09 65 6c 73 | 65 20 69 66 28 6c 6f 77 |+;...els|e if(low|
|00003f50| 3e 2a 6d 69 6e 50 74 72 | 29 6c 6f 77 2d 2d 3b 0d |>*minPtr|)low--;.|
|00003f60| 09 7d 0d 09 2a 6d 69 6e | 50 74 72 3d 6c 6f 77 3b |.}..*min|Ptr=low;|
|00003f70| 0d 09 2a 6d 61 78 50 74 | 72 3d 68 69 67 68 3b 0d |..*maxPt|r=high;.|
|00003f80| 09 2a 75 6e 63 6c 69 70 | 70 65 64 53 64 50 74 72 |.*unclip|pedSdPtr|
|00003f90| 3d 63 6c 69 70 70 65 64 | 53 64 2f 63 6c 69 70 70 |=clipped|Sd/clipp|
|00003fa0| 65 64 53 64 31 3b 0d 7d | 00 00 00 00 00 00 00 00 |edSd1;.}|........|
|00003fb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003fc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003fd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003fe0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003ff0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004000| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00004010| 00 04 00 00 00 07 00 00 | 00 03 00 00 00 00 00 03 |........|........|
|00004020| 00 00 00 08 00 00 00 03 | 00 00 00 00 00 06 00 00 |........|........|
|00004030| 0e 4e 6f 69 73 65 50 64 | 66 46 69 6c 6c 2e 63 4e |.NoisePd|fFill.cN|
|00004040| 02 00 00 00 50 61 72 74 | 53 49 54 21 00 00 00 00 |....Part|SIT!....|
|00004050| 00 00 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |..PartSI|T!......|
|00004060| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004070| 00 00 ab bf ee 67 00 00 | 00 00 00 00 01 9a 00 02 |.....g..|........|
|00004080| 67 74 6f 70 6c 65 76 00 | 02 3f 6e 72 00 02 30 6e |gtoplev.|.?nr..0n|
|00004090| 63 00 01 6a 6a 00 03 d4 | 6c 65 76 00 be ab ba eb |c..jj...|lev.....|
|000040a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000040b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000040c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000040d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 01 00 14 |........|........|
|000040e0| 00 01 00 00 02 e5 70 79 | 72 6e 75 6d 70 69 78 00 |......py|rnumpix.|
|000040f0| 00 00 fe ed be ad 00 00 | 00 00 00 00 11 20 00 00 |........|..... ..|
|00004100| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 00 00 00 |...H..Mo|naco....|
|00004110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004120| 00 00 00 00 00 00 00 03 | 00 04 00 3e 00 04 01 8c |........|...>....|
|00004130| 02 7c 00 3e 00 04 01 8c | 02 7c ab b8 d0 44 00 00 |.|.>....|.|...D..|
|00004140| 3e 79 00 00 3e 7b 00 00 | 3c a1 01 00 00 00 00 04 |>y..>{..|<.......|
|00004150| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00004160| 00 00 00 46 00 a2 25 20 | 22 86 00 00 00 1c 00 46 |...F..% |"......F|
|00004170| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00004180| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00004190| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|000041a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+